...

View Full Version : How do I reset a from that submits to itself?



KeithWarren
12-04-2006, 08:58 PM
I have a form with database driven dropdowns that submit onChange and retain the selected value for the user to see. Is there a function that I could use to reset all of the dropdowns to their default state?

Here's a sample of the form

<form name="selectproducts" id="selectproducts" action="select_products.asp" method="post">

<table width="590" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" colspan="8" align="left" valign="bottom" class="heading">Solder Spheres </td>
</tr>
<tr>
<td width="30" class="bodytext"><div align="center">Item</div></td>
<td class="bodytext"><div align="center">Alloy</div></td>
<td class="bodytext"><div align="center">Size</div></td>
<td class="bodytext"><div align="center">Qty</div></td>
<td class="bodytext"><div align="center">Price / 1000 </div></td>

<td class="bodytext"><div align="center">Lead Time </div></td>
<td class="bodytext"><div align="center">Ext. Price</div></td>
</tr>
<tr>
<td colspan="8" class="hdivider"><div align="center">
<hr />
</div></td>
</tr>
<tr>
<td height="25" class="bodytext"><div align="center">1</div></td>
<td><div align="center">
<select NAME="SphereAlloy1" SIZE="1" ONCHANGE="submit()" style="font-family: Tahoma; font-size: 8pt">
<option> </option>
<%SQL = "SELECT DISTINCT SphereAlloy FROM PriceTable WHERE (Active = 'Active' AND Type = 'S')"
SET RS = Conn.Execute(SQL)
While NOT RS.EOF
%>
<option <%If Request.Form("SphereAlloy1")=RS("SphereAlloy") Then Response.write("selected")End If %>><%=RS("SphereAlloy")%></option>
<%Session("SphereAlloy1") = Request.form("SphereAlloy1")
RS.MoveNext
WEND
Set RS = NOTHING

%>
</select>

</div></td>
<td><div align="center">
<select name="SphereSize1" size="1" onchange="submit()" style="font-family: Tahoma; font-size: 8pt">
<option> </option>
<%Alloy1 = Request.Form("SphereAlloy1")%>
<%SQL = "SELECT DISTINCT SphereSize FROM PriceTable WHERE [SphereAlloy] = '" & Request.Form("SphereAlloy1") & "' "
SET RS = Conn.Execute(SQL)
While NOT RS.EOF
%>
<option <%If Request.Form("SphereSize1")=RS("SphereSize") Then Response.write("selected")End If%>><%=RS("SphereSize")%></option>
<%Session("SphereSize1") = Request.form("SphereSize1")
RS.MoveNext
WEND
Set RS = NOTHING

%>
</select>
</div></td>
<td><div align="center">
<select NAME="SphereQty1" SIZE="1" ONCHANGE="submit()" style="font-family: Tahoma; font-size: 8pt">
<option value="0"> </option>
<%Size1 = Request.Form("SphereSize1")%>
<%SQL = "SELECT SphereQty FROM PriceTable WHERE ([SphereAlloy] = '" & Request.Form("SphereAlloy1") & "' AND [SphereSize] = '" & Request.Form("SphereSize1") & "' )"
SET RS = Conn.Execute(SQL)
While NOT RS.EOF
%>
<option <%If clng(Request.Form("SphereQty1"))=RS("SphereQty") Then Response.write("selected")End If%>><%=RS("SphereQty")%></option>
<%Session("SphereQty1") = Request.form("SphereQty1")
RS.MoveNext
WEND
Set RS = NOTHING
%>
</select>

Thanks for your help.

nikkiH
12-04-2006, 09:24 PM
Is their "default" state always the first item in the list?
If so, set .options[0].selected to true and .selectedIndex to 0 (cross-browser).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum