I have been working with a form submission in joomla and have a few trouble using javascript variable with php JRoute_
Here is the code snippet:
function ValidateForm()
{
var loc = $("#locality").val();
var action = '<?php echo JRoute::_('index.php?option=com_add&view=malllists&Itemid=233&districtname='.$dit.'&loc='Pass javascript Variable Here) ;?>';
document.miniSurveyView481.action = action;
}
In the place of Pass javascript Variable Here I need to pass the loc value I tried plenty of things but Could not find a solution.
You can't use javascript variable in php code. Php code run's on the serverside and javascript code runs in the client side. You can't ask the browser to run php code.
Your variable loc will have a value only when the code reaches the browser.
If you want to get some value from server and combine it with javascript variables then do the following.
Use an ajax request and send the desired values to server. The server will return with a response. Use that response text and store it in your action variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With