DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    navajo Guest

    Code for option box


    Craig:

    This is the first file (has the option box in the design screen):
    <%
    Set MyRecordsetObject=Server.CreateObject("ADODB.Recordset")
    MyRecordsetObject.Open"SELECT name,id FROM catch.counties","DSN=YourData"
    %>



    <form name="getcounty" method="post" action="trial12.asp">



    <SELECT NAME="yoyo" SIZE="1">

    <%
    Set MyRecordsetObject=Server.CreateObject("ADODB.Recordset")
    MyRecordsetObject.Open"SELECT name,id FROM catch.counties","DSN=YourData"

    Do While Not MyRecordsetObject.EOF
    %>


    <OPTION value="trial12.asp"<%=MyRecordsetObject("id")%>"> <%=MyRecordsetObject("name")%>

    <%
    MyRecordsetObject.MoveNext

    Loop

    %>

    </SELECT>
    &nbsp;&nbsp;
    <INPUT type="button" name="Go" value="Go" onClick=""window.location=document.getcounty.yoyo.options[document.getcounty.yoyo.selectedIndex].value">
    </form>

    _________________________________________________________________
    _________________________________________________________________
    This is the second fileshould show data from option box selected):

    <%
    ' -- Get a Recordset Object
    Set MyRecordsetObject = Server.CreateObject("ADODB.Recordset")


    ' -- Retrieve the database information
    MyRecordsetObject.Open "SELECT * FROM catch.counties where name='" & Request.Form("catchtext1")&
    "'" , "DSN=YourData"
    %>
    <table border=1 align=center>
    <tr>
    <td><center><b><i>County Name</i></b></center>
    <td><b><i>Region</i></b>
    <td><b><i>Coastal</i></b>
    <td><b><i>Mil_Base_Cnt</i></b>
    <td><b><i>Population</i></b>
    </tr>
    <%
    ' -- Loop through the employee records in the Recordset Object until End
    Of File
    Do While Not MyRecordsetObject.EOF
    %>
    <tr>

    <td><a href="Doctor.asp"><%=MyRecordsetObject("Name")%></a></td>
    <td><%=MyRecordsetObject("Region")%></td>
    <td><%=MyRecordsetObject("Coastal")%></td>
    <td><%=MyRecordsetObject("Mil_Base_Cnt")%></td>
    <td><%=MyRecordsetObject("Population")%></td>

    </tr>
    <%
    ' -- Move to next employee record
    MyRecordsetObject.MoveNext

    ' -- Continue looping
    Loop
    %>
    </table>



    Thanks.




    "Craig" <cjewiss.nospam@hotmail.com> wrote:
    >Can you post some of your code? It's hard to guess why the value isn't
    >making it to your second page.
    >
    >On the second point, you can use the onchange() event for the select tag

    to
    >submit the form (something like document.formname.submit())
    >
    >Hope that helps.
    >"navajo" <pscmaker@hotmail.com> wrote in message
    >news:39f0c2a2$1@news.devx.com...
    >>
    >> i have items filled in a drop down box, i need to move to another page

    >after
    >> the user selects an option and hits a sumbit button. The results of the

    >selected
    >> option should be displayed on the next page.
    >>
    >> I tried the "request.form" option in the code for my next page, (to get
    >> the value of the selected option)but i'm not being able to get resutlts

    >(only
    >> the table is displayed , not data in it).
    >>
    >>
    >> Secondly, How can i do without the submit button (the user need not click
    >> on a button, juct selecting an option from the drop down box should take
    >> him to the next page.
    >>
    >> Any ideas?
    >>
    >> Thanks.

    >
    >



  2. #2
    Richard Guest

    Re: Code for option box


    Try this:

    First page:
    ...
    <SELECT NAME='id' SIZE='1' onChange="window.location='trial12.asp?id=' +
    document.getcounty.id.options[document.getcounty.id.selectedIndex].value">
    <!--This changes the page when the user selects an option, and passes the
    option in the querystring - only works in a browser that supports scripting-->
    ...

    <OPTION value='<%=MyRecordsetObject("id")%>'><%=MyRecordsetObject("name")%></OPTION>
    <!--Only use the ID as the value, not the URL. Always close the option tags
    -->
    ...

    <INPUT type='submit' name='Go' value='Go'>
    <!--Provide a submit button, for browsers that don't support scripting-->
    ...

    Second page:
    ...
    MyRecordsetObject.Open "SELECT * FROM catch.counties where id=" & Request("id")
    , "DSN=YourData"
    'The ID will either be passed in the QueryString collection (if the browser
    supports scripting), or the Form collection. Omit the collection name to
    try both.
    ...



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links