Hi Everyone!
I need to send a variable returned from a JavaScript function with a form.
<form name="RegForm" method="post" action="/validate_accountinfo.php" onsubmit="send()">
</form>
function send()
{
var number = 5;
return number;
}
In the validate_accountinfo.php I want to return the value of the function. How to do this?
Thanks for advance.
AVADHESH PATEL
12-Mar-2013Hi Samuel!
Add an <input hidden id="thevalue" name="thevalue" /> to the form, set its value using JavaScript and then submit the form.
<form id="RegForm" name="RegForm" method="post" action="/validate_accountinfo.php" onsubmit="send()">
<input hidden id="thevalue" name="thevalue" />
</form>
<script type="text/javascript">
function send()
{
var number = 5;
return number;
}
document.getElementById('thevalue').value = send();
document.getElementById('RegForm').submit();
</script>