Two combos, one textbox exampleHere is the code for this Example Page one <!-- Author: Adrian Forbes --> <%
strconn = "Driver={SQL Server};Description=sqldemo;SERVER=127.0.0.1;UID=LoginID;PWD=Password;DATABASE=Database_Name set conn = server.createobject("adodb.connection") conn.open strconn set objRS = createobject("ADODB.Recordset") objRS.Open "select ID, strParent from Parents", strconn
if Request("cboPrimary") = "" then lPrimary = objRS("ID") else lPrimary = clng(Request("cboPrimary")) end if %> <form name=frmTest action="2Combo1TextboxTarget.asp" method=POST> <p> <select name=cboPrimary size=1 onChange="RefreshPage()"> <%while not objRS.EOF lID = clng(objRS("ID"))%> <option value="<%=lID%>"<%if lPrimary = lID then Response.Write " SELECTED"%>><%=objRS("strParent")%> <% objRS.MoveNext wend objRS.Close objRS.Open "select ID, strChild, intValue from Children WHERE intParent=" & lPrimary, strconn %> </select> <select name=cboSecondary size=1" onChange="PopulateTextbox()"> <%while not objRS.EOF lID = clng(objRS("ID"))%> <option value="<%=lID%>"><%=objRS("strChild")%> <% objRS.MoveNext wend %> </select> <input type=TEXT name=txtValue> <p><input type=SUBMIT value="Submit" id=SUBMIT1 name=SUBMIT1> </form> <% objRS.MoveFirst while not objRS.EOF%> <input type=HIDDEN ID="intValue<%=objRS("ID")%>" value="<%=objRS("intValue")%>"> <%objrs.MoveNext wend objRS.Close set objRS.ActiveConnection = nothing set objRS = nothing %>
<form name=frmRefresh action="2Combo1Textbox.asp" method=POST> <input type=HIDDEN name=cboPrimary> <input type=HIDDEN name=cboSecondary> </form>
<script language=VBScript> sub window_onLoad PopulateTextbox end sub
sub PopulateTextbox lID = document.frmTest.cboSecondary.value document.frmTest.txtValue.value = document.all("intValue" & lID).value end sub
sub RefreshPage frmRefresh.cboPrimary.value = frmTest.cboPrimary.value frmRefresh.cboSecondary.value = frmTest.cboSecondary.value frmRefresh.submit end sub </script>
Page Two <%@ Language=VBScript %> <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> </HEAD> <BODY>
<table border=0> <tr> <td>Primary</td></td><td><%=Request("cboPrimary")%></td> </tr> <tr> <td>Secondary</td></td><td><%=Request("cboSecondary")%></td> </tr> <tr> <td>Value</td></td><td><%=Request("txtValue")%></td> </tr>
</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 developerWorks - FREE Tools! | Join this webcast, to learn how the Rational Process Library can help with compliance issues, drive process improvement, and assist in service-oriented architecture (SOA) or Agile development. We will take a peek into the Rational Process Library with content around software and systems engineering (including RUP), operations and systems management, program and portfolio management, and asset and SOA governance. FREE! Go There Now!
| | | | As businesses grow increasingly dependent upon Web applications to provide services to customers, employees and partners, these complex applications become more difficult to secure. Although traditional security solutions protect Internet infrastructure layers, they do not guard against HTTP and HTML attacks. Many organizations that conduct security testing still deploy applications that allow attackers to manipulate their logic and wreak havoc on their business. To mitigate this risk, development and delivery teams must address Web application security throughout the lifecycle, addressing the many layers detailed in this paper. FREE! Go There Now!
| | | | Download the IBM WebSphere Portal V6.1 beta code and learn more about the rich features and enhancements in IBM WebSphere Portal V6.1. WebSphere Portal provides a composite application or business mashup framework and the advanced tooling needed to build flexible, SOA-based solutions, and scalability to meet the needs of any size organization. FREE! Go There Now!
| | | | Download a free trial version of IBM Rational Developer for System i V7.1, which provides a complete development environment for traditional i5/OS application development. IBM Rational Developer for System i is a new eclipse-based workstation offering for i5/OS application development that provides a comprehensive Integrated Development Environment for edit/compile/debug of traditional RPG/COBOL/C/C++ i5/OS applications. FREE! Go There Now!
| | | | Download a free trial version of IBM Rational Software Analyzer Developer Edition V7.0 to identify bug defects earlier in the software development cycle. Rational Software Analyzer is an extensible software development solution that reduces the expense of bug-fixes by enabling static analysis code reviews and bug identification very early in the development cycle. FREE! Go There Now!
| | | | Join this Rational Talks to You teleconference on December 6 at 1:00 pm ET to participate in an agile application development discussion and get your questions answered on using IBM Rational Method Composer in a distributed environment.Get your questions answered! FREE! Go There Now!
| | | | Discover how Rational tools and best practices for testing can make your job easier. The new Rational Testing eKits provide you with valuable resources – including demos, webcasts, tutorials, and articles – that help you address your specific testing needs across the software lifecycle. Five new eKits are available covering the topics of Requirements and Test Management, Functional Testing, Performance Testing, Code Quality and Embedded Systems, and SOA and Web Services Testing. FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Performance Tester V7.0.1, a load and performance testing solution for teams concerned about the scalability of their Web-based applications. Combining multiple ease-of-use features with granular detail, Rational Performance Tester simplifies the test-creation, load-generation and data-collection processes that help teams ensure the ability of their applications to accommodate required user loads. FREE! Go There Now!
| | | | The Eclipse community is constantly working to extend Eclipse's functionality. In this webcast, learn about some of the most important and feature-rich projects under development. From multi-language support to plug-in development, tune in to see what Eclipse is capable of now. FREE! Go There Now!
| | | | In this webcast, you'll get an introduction to the eXtreme Transaction Processing (XTP) features of WebSphere Extended Deployment and the common architectural traits required by XTP applications. See how WebSphere Extended Deployment's ObjectGrid feature provides a state-of-the-art infrastructure for hosting XTP applications. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |