Hello,
I want to pass javascript variables to php using hidden input of a form.
But i have met a problem here, the $salarieid can't get the value from $_POST['hidden1']. Is there something wrong?
Here is the code:
<script type="text/javascript">
// view which the user has chosen
function func_load3(name){
var oForm = document.forms["myform"];
var oSelectBox = oForm.select3;
var iChoice = oSelectBox.selectedIndex;
//alert("you have choosen: " + oSelectBox.options[iChoice].text );
//document.write(oSelectBox.options[iChoice].text);
var sa = oSelectBox.options[iChoice].text;
document.getElementById("hidden1").value = sa;
}
</script>
<form name="myform" action="<?php echo $_SERVER['$PHP_SELF']; ?>" method="POST">
<input type="hidden" name="hidden1" id="hidden1" />
</form>
<?php
$salarieid = $_POST['hidden1'];
$query = "select * from salarie where salarieid = ".$salarieid;
echo $query;
$result = mysql_query($query);
?>
<table>
code for display the query result.
</table>
Thanks for your advice.