I have a HTML form that submits to PHP. There is an onChange event on a drop down box that calls a JavaScript function which writes a hidden variable into the form. This additional hidden variable doesnt show up in PHP though, why is this?
So;
<script language="JavaScript">
function change() {
document.getElementById("myDiv").innerHTML="<input type=\"hidden\" name=\"blah\" value=\"1\"/>";
return;
}
</script>
<form method="post" action="test.php" />
<select name="cid" id="cid" onChange="change();">
<option value="lala">lala</option>
</select>
<div id="myDiv"></div>
</form>开发者_C百科;
PHP doesn't see $_POST['blah']?
A more logical solution anyway would be to just add the hidden field to your form, and set the value to 1 in the onChange function.
You must have been setup something wrong, it dose work fine when I test that. Are you sure you call the method before you submit the form ?
I can´t see you executing your change() function.
精彩评论