how to do selected option to submit different php page
by Jayanthi[ Edit ] 2012-05-30 10:52:48
Selected which option to submit specific page..
if choose milk, the myform submit milk.php page.
otherwise, submit mixed.php.
<script>
function change()
{
var sel=document.getElementById('psel').value;
if(sel === 'milk') {
document.getElementById('myform').action = 'milk.php';
} else {
document.getElementById('myform').action = 'mixed.php';
}
}
</script>
<form name='myform' method='post' action='milk.php'>
Username : <input type='text' id='user' name='user'> by
<select id='psel' name='psel' onchange='change()'>
<option value='milk'>Milk</option>
<option value='coffee'>Coffee</option>
<option value='tea'>Tea</option>
</select>
<input type='submit' name='sub' id='sub' value='Go'>
</form>