Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I reset a from that submits to itself?

    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.

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    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).

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •