Web form question

supergper

Gawd
Joined
Apr 25, 2005
Messages
766
OK, so I have a web form I'm trying to "format". What I have is a web form that submits to a page that interacts with a database. I have it so they can insert, update, and delete through a stored procedure, and they can also query through a basic select statement. It works exactly as I want it to, so that's not the issue. What I would like is to only show certain fields based on what action they are doing (insert, update, delete, or query). I found a piece of javascript that allows me to toggle the fields when I click it, but I want it to do it when the menu item is selected. So if I select query, I only see the one field that gets queried and the conditional (equal to or like) field.

Any suggestions?

Here is my web form code:

Code:
<html>
<head>
<title>Add, Remove, or Query Printers</title>
<script language="JavaScript">
function toggleFields() {
  if(document.getElementById) {
    var tmp = document.getElementsByTagName('div');
    for (var i=0; i<tmp.length; i++) {
      if(tmp[i].className == 'conditional2') {
        tmp[i].style.display = (tmp[i].style.display == 'none') ? 'block' : 'none';
   } 
     }
  }

}
</script>

</head>
<body>
<p><a href="#" onclick="javascript:toggleFields();">Toggle fields</a></p>

<H3>Add, Update, or Remove Pritners:</H3>
<form action="printeradd.php" method="post">
<table>
<tr>
<td>
<div class = "required">
Action: <select name="edit_flag">
<option value="U">Add/Update</option>
<option value="D">Delete</option>
<option value="Q">Query</option>
</select>
</div>
</td>
<td>
<div class = "conditional1">
Condition: <select name="condition">
<option value="Like">Is Like</option>
<option value="=">Is Exactly</option>
</select><br>
</div>
</td>
</tr>
<tr>
<td>
<div class = "required">
Printer Name: <input type="text" name="location_id"><br>
</div>
</td>
</tr>
<tr>
<td>
<div class = "conditional2">
Description: <input type="text" name="description"><br>
</div>
</td>
</tr>
<tr>
<td>
<div class = "conditional2">
Warehouse ID: <input type="text" name="wh_id" value="WSL"><br>
</div>
</td>
</tr>
</table>
<input type="Submit">
</form>
</body>
</html>
 
Back
Top