Displaying field selection
Hello,
I have a form that saves input by users. There is a mixture of textboxes and 5 drop down selection menus. 2 of the select menus are linked. One is to select the type of inventory and the other the category of inventory. When a user selects a 'Type', for example; 'Tools' then the category part will list down all that has to do with tools only, instead of displaying all the categories in one go. The purpose is to ease the selection of category.
To show this I used the onSubmit() function on the 'Type' select. Each time the user select an option the page will refresh. This causes all the entries in the textboxes to clear as well. If i add in the action="page.asp" into the form section, each time the 'Type' is selected then the page is submitted as well. This is a section of my code. Please hrlp and advice.
<html>
<body>
<FORM id="form1" name="form1" method="post" action="form2.asp">
<input type="text" name="Item" size="17">
<SELECT name="types" OnChange="form1.submit();">
<option name="XYZ" value="-">Select a type</option>
<% Types.MoveFirst
Do While Not Types.EOF
Response.Write "<option value=" &Types("type_id")& ">" & Types ("type_name")
Types.MoveNext
Loop
%>
</SELECT>
<SCRIPT>
selectItem( form1.types );
function selectItem( sel )
{
var i
for( i = 0; i < sel.options.length; i++ )
if(sel.options[i].value == <%= "'" & Request.form("types") & "'" %> )
sel.options[i].selected = true;
}
</SCRIPT>
<SELECT name="category">
<option name="ABC" value="-">Select a category</option>
<%Cat.MoveFirst
Do While Not Cat.EOF
if Cat("type_id") = Cint(Request.Form("types")) Then
Response.Write "<option value =" & Cat("cat_id")& ">" & Cat("cat_name")
end if
Cat.MoveNext
Loop
%>
<INPUT type="submit">
</FORM>
</body>
</html>
|