Actually My question is after onclick My Modal is appear and i can insert multiple things into the Modal and i can do this through
(.html("abc");)
But the above syntax is insert only one string if i append multiple String it's shows error
Here is my Code:
echo "<script>
function myFunction(order){
$('.modal-body').html(order.order_id);
$('#myModal').modal({backdrop: false}); /#myModal is the body of the Modal
}
</script>";
Now i find out the soloution we can use this:
$('.modal-body').html('<b>Order Number</b>: '+order.order_id +
'<br>'+'<b>Order Date:</b>' + ' ' +order.created_date+ '<br>'+'<b>Table Number:</b>' + ' ' +order.uid + '<br>'+'<b>Status:</b> ' + ' ' +order.status+ '<br>'+'<b>Title:</b>' + ' ' +order.title + '<br>'+'<b>Quantity:</b>' + ' ' +order.quantity+ '<br>'+'<b>Personalization:</b>' + ' ' +order.personalization);
Related
Is there any way to use a form in leaflet mapping to open another page?
I'm using a post route for this and have even tried embedding it in an tag but to no avail.
At the moment the form data is in a for loop like so
map_data.forEach(element => {
console.log('program=' + element.program + ', lat=' + element.gps_lat + ', long=' + element.gps_lon);
data[i] = L.marker([element.gps_lon, element.gps_lat], {icon: redIcon}).addTo(map);
var url = '{{ route("opentraining", ":training_id") }}';
var alt_url = '{{ route("opentraining") }}';
url = url.replace(':id', element.id);
data[i].bindPopup(
'<strong>' + element.program + '</strong>'
+ '<br />'
+ '<b>Location:</b> ' + element.location + ', ' + element.district + ', ' + element.province
+ '<br />'
+ '<b>Description:</b> ' + element.description
+ '<br /><br />'
+ '<form onsubmit="' + alt_url + '" method="POST" class="formEditTraining">#csrf<input type="hidden" name="training_id" value='+ element.id + '>'
+ '<button type="submit" value="submit" class="btn btn-primary trigger-submit">View Record</button>'
+'</form>'
).openPopup();
i++;
});
Even when use the route directly within the form it makes no difference all I get is an error saying POST method isn't supported.. What could I be missing ?
You're using the wrong attribute for the URL in your <form> tag. onsubmit is for specifying a JS function to run before the form is submitted. To specify the URL you want to submit the form to, use action. Since you are not specifying action at the moment, it's posting it back to the same URL that the form is on, which evidently is not set up to receive POSTs.
I am trying to escape a string and it currently looks like this:
... onclick="anotherfunction(\'bla\',\'bla\'); myfunctionhere(\'/path1/path2/\'' + val.param1 + '\', \'' + val.param2 + '\', \'' + val.param3 + '\')";
Something is still wrong with it because val.param1 is there but still with an additional ' in front.
Lets say val.param1 is 4711 then the first part of myfunctionhere is being renders as
/path1/path2/'4711
How do I solve this? Removing the second ' does not help.
Ah, got it working right now:
... onclick="anotherfunction(\'bla\',\'bla\'); myfunctionhere(\'\/path1\/path2\/' + val.param1 + '\', \'' + val.param2 + '\', \'' + val.param3 + '\')";
I am trying to pass variables to a javascript function but i have the Javascript Error: 'missing ) after argument list"
html = html + '' + 'Lugar: ' +name.name +' Coordenadas: Lat '+ name.lat +' Lng'+ name.lng+ '<br>';
It doesn't look like I am missing any ')'s.
I see you have found your solution, but here's an alternative anyway, which reduces your string concatenation a little. There's still a far better way of achieving this, but this may help you start to see the benefit of moving away from building HMTL via string concatenation.
<meta charset="UTF-8">
<span id="spanTest"></span>
<script>
// Or whatever your initMap2 function does...
function initMap2(lat, lng, name) {
console.log('Lat: ' + lat);
console.log('Lng: ' + lng);
console.log('Name: ' + name);
}
var spanTest = document.getElementById('spanTest');
var worldLocation = { name:"test", lat:98.5, lng:-88.45 };
var anchor = document.createElement('a');
anchor.href = 'javascript:initMap2(' + worldLocation.lat +', ' + worldLocation.lng + ', \'' + worldLocation.name + '\');';
anchor.innerHTML = 'Name: ' + worldLocation.name + ', Lat: ' + worldLocation.lat + ' Lng: ' + worldLocation.lng;
spanTest.appendChild(anchor);
</script>
I'm assuming your last argument is expected to be a string, but it's resolved to look like a variable. Try this instead:
html = html + '<a href="javascript:initMap2(' + name.lat +','+ name.lng +',\''+ name.name +'\');">' // etc.
When name.name resolves to a string, it'll be wrapped in single quotes as expected. It'll look something like javascript:initMap2(1, 2, 'someString').
I am creating a new html tab that among other things will show a table. I leave the table empty because i will fill it after with a Dynatable JS (filles a table with a given JSON). Code:
var html_ticket = '<!doctype html>' +
'<html dir="ltr" lang="en" class="no-js">' +
'<head> ' +
(...)
'</head> ' +
'<body> ' +
(...)
' <table id="ticket_table" > ' +
' <thead> ' +
' <th>Timestamp</th> ' +
' <th>Amount</th> ' +
' </thead> ' +
' <tbody> ' +
' </tbody> ' +
' </table> ' +
(...)
'</body> ' +
'</html> ';
Then i open that html code in a new tab like this:
var newWindow = window.open();
newWindow.document.write(html_ticket);
Ok the next thing i need to do is to fill the table with the info. I am using a JS that fills the table with a given JSON. I've used it several times and worked perfect, but this time the table is not filled, keeps empty. Code:
var table = newWindow.document.getElementById('ticket_table');
table.dynatable({
features: {
paginate: true,
sort: false,
pushState: false,
search: false,
recordCount: true,
perPageSelect: false
},
dataset: {
records: getInfoJSON()
}
});
I am suspecting that I am not accessing the new windows's element properly.. could this be the issue?
I am trying to create email templates just using an html file. This file will display a list of mailto links that, when clicked, will open a template with message. I got it working for the most part but some of these templates use prompts to add information to the message before creating it. The problem is that it doesn't seem to work right. Here is my code.
function sendReport(emailName, addresseList){
document.writeln('<a onClick="setPrompt(this,\'' + addresseList + '\')" href="mailto:' + addresseList + '?subject=' + 'Report' + '&body=' + 'Here is the report.' + '">' + emailName + '</a><br />');
}
function setPrompt(obj, addresseList){
var reportName = prompt("Report name","");
obj.attr('href', ='mailto:' + addresseList + '?subject=' + reportName + '&body=' + "Here is the report."); //<-- this is the line that is giving me trouble.
}
You have a typo in the last line and there is no .attr() built in function in Javascript. This should fix it:
obj.setAttribute('href', 'mailto:' + addresseList + '?subject=' + reportName + '&body=' + "Here is the report.");