I have a form which will show hidden <div> on selection of a dropdown menu item. My problem is when the form is submitted, all the hidden <div> form elements are sent. I either need to clear all hidden <div> form fields before submit or only submit the visible <div>.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<style>
.hide{
display:none;
}
</style>
<script type="text/javascript">
// script that shows the hidden div associated with dropdown choice when selected
var lastSelection1 = undefined;function handleSelection1(choice) {
document.getElementById('name').disabled=false;
document.getElementById(choice).style.display="block";
if ( lastSelection1 != undefined ) {
document.getElementById(lastSelection1).style.display="none";
}
lastSelection1 = choice;
}
</script>
</head>
<body>
<form name="seForm" method="POST" action="some_web_page">
<select id="name" onChange="handleSelection1(value)" size="1" name="command">
<option value="clear" selected></option>
<option value="option one">option one</option>
<option value="option two">opttion two</option>
<option value="option three">option three</option>
</select>
<!-- START OF A NEW COMMAND -->
<div class="hide" id="se_clear">
</div>
<!-- START OF A NEW COMMAND -->
<div class="hide" id="option one">
<div align="center">
<center>
<div align="left">
<table border="0" cellspacing="0">
<tr>
<td valign="middle" width="30%">
<p align="right">Slot: </td>
</center>
<td valign="middle" width="70%">
<p align="left"><input type="text" id="slot" size="20" name="slot"></p>
</td>
</tr>
<center>
<center>
<tr>
<td valign="middle" width="30%">
<p align="right">Port: </td>
</center>
</center>
<td valign="middle" width="70%">
<p align="left"><input type="text" id="port" size="20" name="port"></p>
</td>
</tr>
</table>
</div>
<p align="left">
<input type="submit" value="Submit">
</div>
</div>
<!-- START OF A NEW COMMAND -->
<div class="hide" id="option two">
<div align="center">
<center>
<div align="left">
<table border="0" cellspacing="0">
<tr>
<td valign="middle" width="30%">
<p align="right">Name: </td>
</center>
<td valign="middle" width="70%">
<p align="left"><input type="text" id="age" size="20" name="name"></p>
</td>
</tr>
<center>
<center>
<tr>
<td valign="middle" width="30%">
<p align="right">Age: </td>
</center>
</center>
<td valign="middle" width="70%">
<p align="left"><input type="text" id="age" size="20" name="age"></p>
</td>
</tr>
</table>
</div>
<p align="left">
<input type="submit" value="Submit">
</div>
</div>
<!-- START OF A NEW COMMAND -->
<div class="hide" id="option three">
<div align="center">
<center>
<div align="left">
<table border="0" cellspacing="0">
<tr>
<td valign="middle" width="30%">
<p align="right">Phone: </td>
</center>
<td valign="middle" width="70%">
<p align="left"><input type="text" id="phone" size="20" name="phone"></p>
</td>
</tr>
<center>
<center>
<tr>
<td valign="middle" width="30%">
<p align="right">Age: </td>
</center>
</center>
<td valign="middle" width="70%">
<p align="left"><input type="text" id="address" size="20" name="address"></p>
</td>
</tr>
</table>
</div>
<p align="left">
<input type="submit" value="Submit">
</div>
</div>
</form>
</body>
</html>