Yup, seeing what you want to do here. If you want to post data from a form, you’ll have to submit the form to a page that will accept its data, for example pg1.php.
One way to do it would be to change the “action” attribute of the form on the fly and then calling the submit method.
e.g.:
//set the form action
var myForm = document.getElementById("theForm"); //assuming you added the id="theForm" to your form
myForm.action = url;
//and submit the form. This will make sure that form field data will get passed along
myForm.submit();
Should I put your code in function ddmOnChange() like the below?
<script type='text/javascript'>
window.onload = function()
{
document.getElementById('goDirect').onchange = ddmOnChange;
}
function ddmOnChange()
{
var url = this.options[this.selectedIndex].value;
document.location = url;
[COLOR="#FF0000"]var myForm = document.getElementById("theForm"); //assuming you added the id="theForm" to your form
myForm.action = url;
//and submit the form. This will make sure that form field data will get passed along
myForm.submit();[/COLOR]
}
</script>
<form method="post">
<input type="text" name="theForm" value="myText">
<select id='goDirect'>
<option>select</option>
<option value='pg1.php'>Page 1</option>
<option value='pg2.php'>Page 2</option>
</select>
</form>
However, the code above seems not to pass the form data to pg1.php or pg2.php.