Re: onchange event of dropdown box...more


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Re: onchange event of dropdown box...more

  1. #1
    Sean gallaghar Guest

    Re: onchange event of dropdown box...more


    Thanks M.f!

    --i created two forms on my page (one for the text box and attached submit
    button and another for the dropdown box and its onchange event). I used what
    you said:

    <select id=select1 onchange='document.forms["myForms"].submit

    and it takes me to the next page. I know its picking the value of the item
    selected from the dropdown box - the value of the selected item is displayed
    in the last part of the url for the next (hospitals.asp) page:

    ".....hospitals.asp?yourname=Lafayette"

    -Lafayette is the item selected form the dropdown box. However, the dropdown
    on hospitals.asp(next page) for results corresponding to Lafayette is not
    getting populated.The SQL is okay,though.I made a fresh page with a submit
    button next to the dropdown box and it works fine.On the actual page, hpowever,
    i can only use one submit button (for the text box)..anyway i would prefer
    to use the onchange event for the dropdown.


    Any clues? Thanks.


    "mad fiddler" <madfiddler@hotmail.com> wrote:
    >
    >
    >maybe its the way you showed your example - I'm not sure, but what is the
    >value of your dropdown box item? Also "thehref" does not appear to be used
    >for anything.
    >
    >you say it doesn't work - well what actually happens?
    >
    >By changing location.href you are not posting the results of your selection
    >to hospitals.asp
    >
    >Suggest you do something like -
    >
    ><form id=myForm" method="POST" action="hospitals.asp">
    > ()'>
    > ....
    > ....
    >
    >
    >
    >hope that helps
    >mf



  2. #2
    mad fiddler Guest

    Re: onchange event of dropdown box...more



    Are you two forms on the same page both posting to hospitals.asp?
    Why not have one form rather than two? You can still have a submit button
    AND script a form submission on the onchange event of your dropdown box.

    At the mo, if you click on the submit button it will be only the results
    of the form that it belongs to that are being posted to your next page, so
    you wont't get the dropdown box info passed through.


    <form id=myForm action="hospitals.asp" method="post">

    <input id=myTextBox type="text" size="20"><br><br>
    <select id="select1" onchange='document.forms"myForms"].submit'>
    <option value="0">item0</option>
    <option value="1">item1</option>
    <option value="2">item2</option>
    </select>
    <input type=submit value"Submit">

    </form>



    Your lookup on the next page to fill another dropdown based on a db lookup
    and the value entered on the posting pages dropdown would be something like

    <%
    Set objConnection = Server.CreateObject("ADODB.Connection")
    objConnection.Open myConnectionString

    Select Case request.form("select1")
    Case 0 mySql = "SELECT FieldA FROM Table0 ORDER BY FieldA"
    fieldName = "FieldA"
    Case 1 mySql = "SELECT FieldB FROM Table1 ORDER BY FieldB"
    fieldName = "FieldB"
    Case 2 mySql = "SELECT FieldC FROM Table2 ORDER BY FieldC"
    fieldName = "FieldC"
    End Select

    Set rS = Server.CreateObject("ADODB.Recordset")
    rS.Open mySql, objConnection
    %>

    <select size="1" name="secondDropDown">
    <% Do While Not rS.EOF
    <option value="<%=rS(fieldName)%>">
    <%=rsName(fieldName)%>
    </option>
    <% rS.MoveNext
    Loop
    rS.Close
    Set rS = Nothing
    objConnection.Close
    Set objConnection = Nothing %>
    </select>


    does that answer your question?!?!?!? )




    "Sean gallaghar" <seangallaghar@hotmail.com> wrote:
    >
    >Thanks M.f!
    >
    >--i created two forms on my page (one for the text box and attached submit
    >button and another for the dropdown box and its onchange event). I used

    what
    >you said:
    >
    ><select id=select1 onchange='document.forms["myForms"].submit
    >
    >and it takes me to the next page. I know its picking the value of the item
    >selected from the dropdown box - the value of the selected item is displayed
    >in the last part of the url for the next (hospitals.asp) page:
    >
    >".....hospitals.asp?yourname=Lafayette"
    >
    >-Lafayette is the item selected form the dropdown box. However, the dropdown
    >on hospitals.asp(next page) for results corresponding to Lafayette is not
    >getting populated.The SQL is okay,though.I made a fresh page with a submit
    >button next to the dropdown box and it works fine.On the actual page, hpowever,
    >i can only use one submit button (for the text box)..anyway i would prefer
    >to use the onchange event for the dropdown.
    >
    >
    >Any clues? Thanks.
    >
    >
    >"mad fiddler" <madfiddler@hotmail.com> wrote:
    >>
    >>
    >>maybe its the way you showed your example - I'm not sure, but what is the
    >>value of your dropdown box item? Also "thehref" does not appear to be used
    >>for anything.
    >>
    >>you say it doesn't work - well what actually happens?
    >>
    >>By changing location.href you are not posting the results of your selection
    >>to hospitals.asp
    >>
    >>Suggest you do something like -
    >>
    >><form id=myForm" method="POST" action="hospitals.asp">
    >> ()'>
    >> ....
    >> ....
    >>
    >>
    >>
    >>hope that helps
    >>mf

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center