Please help me solve a problem on passing the value form javascript function to the 'hidden' form and the form will be submitted to the php code for processing the data. Here are my codes below:
First i have a link which will trigger the function 'passValue()' that holds 3 values.
<a href="javascript: passValue('1','student','1')">Pass Values</a>
Here in my script, i want to pass the data to a form and this values are hidden.
<script type="text/javascript">
function passValue(idNumber,userType,foreignNumber){
document.myForm.id.value = idNumber;
document.myForm.type.value = userType;
document.myForm.typeId.value = foreignNumber;
}
</script>
I assume that the values of the 'hidden' input forms are already set. So I trigger the submit button to send the data to php code which is in another page using a jquery and ajax(but i did not include it anymore in this post) so that the page would not refresh.
<form method="post" name="myForm" action="process.php">
<input type="text" name="myText" />
<input type="hidden" name="id" />
<input type="hidden" name="type" />
<input type="hidden" name="typeId" />
<input type="Submit" name="Submit" value="Send" />
</form>
Here is the php code 'process.php' that will receive the data sent by the form 'myForm'.
<?php
if($_POST){
$id=$_REQUEST['id'];
$type=$_REQUEST['type'];
$typeId=$_REQUEST['typeId'];
}
?>
Problem: I found out that the values of the hidden forms are empty or no values has been set. In this case i assume that the data that has been set by the javascript for those 'hidden' forms cannot be passed to another page or code. Please help...what should i do?