ASP Code
  Home arrow ASP Code arrow 2 DropDown box's to display data, choose o...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP CODE

2 DropDown box's to display data, choose one list box and the other on changes to display data!
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 19
    1999-09-01

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    This demo uses 2 list box's, both are populated by a database. Depending on the selection that is chosen in the first dropdown box, the results will reflect that choice. I've received countless email's how to use 2 listbox's on the same page that are interconnected. I've used frames in this demo, below is both the frames page and the individual pages w/the code.

     

     

    The main frame page-This page ties all the individual pages together.

    <html>
    <head>
    <title></title>

    </head><frameset rows="15%,*" border="0" frameborder="0" framespacing="0">
    <frameset cols="20%,*" border="0" frameborder="0" framespacing="0">
    <frame name="left" src="frame1.asp">
    <frame name="right" src="frame2.asp">
    </frameset>
    <frame name="bottom" src="bottom.asp">
    <noframes>
    <p>This page uses frames, but your browser doesn't support them. </p>
    </font></body>
    </noframes>
    </frameset>

    </html>

    Frame1.asp -This contains the dropdown box that people choose the entry's.

    <%
    'Good coding practices to declare all your local variables
    Dim conn
    Dim rs
    Dim strconn
    Dim DBQValue


    ' Automatic DataConnection
    ' This value is generated on the fly
    Session("DataConn_ConnectionString") = _
    "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("2listbox.mdb")
    ' End of Automatic DataConnection
    strconn= Session("DataConn_ConnectionString")
    set conn= server.createobject("adodb.connection")
    set rs= server.createobject("adodb.recordset")
    conn.open strconn
    strsql="SELECT * FROM dropdown"
    rs.open strsql, conn, 2, 2 %>


    I do an if statement to determine what browser people are using. If a person is using Internet Explorer this will load this version of the html page. Or below in the Else it will load a dropdown with a submit button. I de-test javascript and could have used client code to submit the form, but I'm prefer this way. It might not be the correct way but what the heck this is free code!

    <% If Instr(request.servervariables("http_user_agent"), "MSIE") Then %>

    <html>

    <head>
    <title>Demo Drop Down</title>
    </head>

    <body>
    <script language="vbscript">
    sub submitthis

    form1.submit

    end sub
    </script>

    <p>Select from the dropdown menu</p><br>
    <form ACTION="frame2.asp" METHOD="POST" NAME="form1" target="right">
    <p><select ONCHANGE="submitthis" SIZE="1" NAME="one">
    <% Do While Not rs.EOF %> <option value="<% = rs("type") %>"> <% = rs("field1") %></option>
    <% rs.movenext %><% loop %> </select> <br>
    </p>
    </form>
    </body>
    </html>


    'This part of the If statement is loaded if the browser is netscape! Sorry but this person selects
    'the information and has to click the submit button!
    <% Else %>

    <html>
    <head><title>dude></title></head>
    <body>

    <p>Select from the dropdown menu</p><br>
    <form ACTION="frame2.asp" METHOD="POST" NAME="form1" target="right">
    <p><select SIZE="1" NAME="one">
    <% Do While Not rs.EOF %> <option value="<% = rs("type") %>"> <% = rs("field1") %></option>
    <% rs.movenext %><% loop %> </select> <br>
    <input type="submit" name="b1" value="submit"></p>
    </form>
    </body>
    </html>
    <% End If %>

    <%
    rs.close
    conn.close
    set rs = nothing
    set conn = nothing

    %>

    Frame2.asp - This page shows the resultset that is chosen from the first dropdown box.

    <%
    'Good coding practices to declare all your local variables
    'Does an If statement to see if the request("one") dropdown menu has a value or not
    If request("one") <> "" Then
    %>
    <%
    Dim conn
    Dim rs
    Dim strconn
    Dim DBQValue
    ' Automatic DataConnection
    ' This value is generated on the fly
    Session("DataConn_ConnectionString") = _
    "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("swynk2.mdb")
    ' End of Automatic DataConnection
    strconn= Session("DataConn_ConnectionString")
    set conn= server.createobject("adodb.connection")
    set rs2= server.createobject("adodb.recordset")
    conn.open strconn
    strsql="SELECT table1.fielddata FROM table1 WHERE ((table1.fieldkey)='" & request("one") & "');"
    rs2.open strsql, conn, 2, 2
    %>
    <html>
    <head>
    <title>Load when Empty</title>
    </head>
    <body>
    <form>
    <p>The results of what was selected from the first dropdown.</p><br>
    <p><select name="d2" size="1">
    <% Do While Not rs2.EOF %> <option value="<% = rs2("fielddata") %>"><% = rs2("fielddata") %></option>
    <% rs2.movenext %><% loop %> </select><br>
    </p>
    </form>
    </body>
    </html>
    <%
    rs2.close
    conn.close
    set rs2 = nothing
    set conn = nothing
    %>


    This part gets loaded when the page first loads, when it first loads it is just a blank dropdown box.

    <%
    Else
    %>
    <html>
    <head>
    <title>Load when Empty</title>
    </head>
    <body>

    <form>
    <p><select name="d1" size="1">
    <option value=""></option>
    </select><br>
    </p>
    </form>
    </body>
    </html>
    <% End If %>

    Bottom.asp - This is the major portion of the screen, this is just an example of populating something from the 2nd dropdown menu. This could be instructions or whatever!

    <html>

    <head>
    <title></title>
    </head>
    <body>
    <center>From the 2nd Drop down results could load something to this page<br>I'm still working on this demo so check back for enhancements!
    </center>
    </body>
    </html>


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More ASP Code Articles
    More By aspfree

     

    IBM® developerWorks developerWorks - FREE Tools!


    Be the first to hear about i5/OS V6R1!

    Hold your calendar on January 30, 2008 for this free webcast on the new i5/OS. Rational's Enterprise Modernization products will be discussed at this webcast as they help to drive the application development environment for this new System i OS. <br />And learn how i5/OS will take you to the next step of efficient, resilient business processing. You will hear about the new i5/OS capabilities as it will be the most significant i5/OS release in years. If you cannot join the webcast on 1/30/08 you can still use this link to listen to the replay.<br />
    FREE! Go There Now!


    NEW! Best Practices in Integrated Requirements Management

    Poor Requirements Management capabilities in an Enterprise have been linked to excessive project failures, escalating IT costs, and failure to deliver competitive advantage into the marketplace. Join Brianna M Smith from IBM Rational and learn about how successful organizations align IT and Business stakeholders through collaborative processes and tools for effective requirements management, and how an integrated approach across the IT lifecycle can provide unparalleled visibility and traceability to ensure that project teams are delivering on the business vision by "doing the right things" and "doing things right."
    FREE! Go There Now!


    NEW! IBM Enterprise Modernization Sandbox for System z: Architecture

    Analysts, architects, and developers who have existing COBOL or PL/I skills and want to extend those skills to deploy new workloads on the mainframe can use the IBM Enterprise Modernization Sandbox for System z to find hands-on walkthroughs of common real world scenarios. The scenarios provide examples of how to rapidly design, create, assemble, test, and deploy high-quality Web, Web services, portal, and SOA applications for IBM CICS, IBM IMS, and IBM WebSphere Application Server.
    FREE! Go There Now!


    NEW! Accelerating Software Innovation on i on Power Systems

    Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, for an overview of Rational’s new software offerings and resources to help modernize and accelerate software innovation on i on Power Systems – while ensuring past application investments are protected and continue to grow. Learn how these solutions are helping customers extend their core i5/OS solutions toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time.
    FREE! Go There Now!


    NEW! Try IBM Rational Asset Manager V7.0 online!

    You can now evaluate IBM Rational Asset Manager V7.0 online without installing or configuring it on your own system! Rational Asset Manager helps create, modify, govern, find, and reuse any type of development assets, including SOA and systems development assets. Rational Asset Manager helps you reduce software development costs and improve quality by facilitating the reuse of all types of software development-related assets. Visit developerWorks to learn more about this product and register to explore its capabilities online.
    FREE! Go There Now!


    NEW! Applying lean thinking to the governance of software development

    Effective governance for lean development isn’t about command and control. Instead, the focus is on enabling the right behaviors and practices through collaborative and supportive techniques. Hear from Scott Ambler on how it is far more effective to motivate people to do the right thing than it is to force them to do so. Learn how to form a lightweight, collaboration-based framework that reflects the realities of modern IT organizations.
    FREE! Go There Now!


    NEW! Test terminal-based applications with Rational Functional Tester

    Regression testing -- in which code is thoroughly tested to ensure that changes have not produced unexpected results -- is an important part of any development process. But many testing environments neglect the terminal-based applications that still form the backbone of many industries. In this tutorial, you'll learn how the Rational Functional Tester Extension for Terminal-Based Applications works with other Rational Functional Tester to help test terminal-based applications quickly and easily.
    FREE! Go There Now!


    NEW! Download a free trial of WebSphere Business Modeler Advanced V6.1.1

    Visit IBM developerWorks to download a free trial version of WebSphere Business Modeler Advanced V6.1.1, IBM’s premier business process modeling and analysis tool for business users that offers process modeling, simulation, and analysis capabilities. IBM WebSphere Business Modeler helps you visualize, understand, and document business processes for continuous improvement.
    FREE! Go There Now!


    Role of Integrated Requirements Management in Software Delivery

    As organizations integrate software into every aspect of business, they are constantly pressured to deliver faster, better, and cheaper results. Unfortunately, a “dis-integrated” software delivery approach reduces returns while increasing costs. This IBM Rational White Paper shows how Integrated Requirements Management aligns organizations around maximizing value and keeping pace with change.
    FREE! Go There Now!


    NEW! Addressing software-as-a-service challenges using Tivoli security and WebSphere solutions

    Building a software-as-a-service solution requires addressing a few key technical challenges. In this webcast, we'll focus on the role of IBM Tivoli Directory Server and WebSphere Portlet Factory in creating a Software as a Service solution. We will demonstrate how to use Tivoli Directory Server to prevent the user population of one tenant from accessing the virtual portal and portlet components of another tenant. We will also use the dynamic profile capability of WebSphere Portlet Factory to create multiple highly customized applications from one code base.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP CODE ARTICLES

    - ASP Forms
    - ASP: The Beginning
    - Getting Remote Files With ASP Continued
    - Inbox and Outbox Manipulation in ASP
    - Relational DropDownList Using VB.NET
    - Ad Tracking URL Hits
    - Use ViewState to display one record per page...
    - Send Email using ASP.NET formatted in HTML
    - ASP File Explorer
    - ASP/XML Interview questions by Srivatsan Sri...
    - Pressing RETURN won't submit the form
    - This shows how you get the TEXT of a combo r...
    - Group Data by Adrian Forbes
    - Multiple checkbox select sample
    - Multiple checkbox select with all values sam...





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek