This code reads two combos and displays the information along with one text box of values. Two combos, one textbox example Here 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 Database Code Articles More By Adrian Forbes developerWorks - FREE Tools! | Discover how IBM Rational AppScan Standard Edition can help you detext vulnerabilities in your web applications in the Web Application Security eKit. IBM Rational AppScan is a leading suite of automated web application security solutions that scan and test for common Web application vulnerabilities. The new Web Application Security eKit provides you with valuable resources, including white papers, demos, and additional information on the benefits of testing your Web 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!
| | | | Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services. FREE! Go There Now!
| | | | Ken Krugler, co-founder of code search company Krugle, and Laura Merling, vice president of Marketing and Business Development for Krugle, join to talk about the ins and outs of code search and what it means as a new feature for developerWorks users. FREE! Go There Now!
| | | | Rational Modeling Extension for Microsoft .NET enhances usability for code generation supporting a more intelligent refactoring. The latest enhancements enable organizations with Java and .NET systems and software development maintain architectural integrity across heterogeneous platforms. FREE! Go There Now!
| | | | As organizations have grown increasingly dependent on online software, the risk of malicious attacks has also become far more serious. Fortunately, well-governed organizations can protect their Web applications by injecting vulnerability assessments and ethical hacks into their software development and delivery processes. This paper describes 12 of the most common hacker attacks and provides basic rules that you can follow to help create more hack-resistant Web applications. FREE! Go There Now!
| | | | Get a free trial download of IBM Lotus Forms V3.0 (formerly Workplace Forms), which provides a zero-footprint eForms solution to help you automate and move forms-based business processes off the desktop and onto the Web. With Lotus Forms, you can extend applications beyond the firewall by creating a single electronic form document ready for use in both thick and Web 2.0 thin client format. FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Method Composer V7.2 which helps you deliver customized yet consistent process guidance to your project teams and IT organization, and includes the latest version of IBM Rational Unified Process (RUP), which has provided process guidance to teams since 1996. FREE! Go There Now!
| | | | Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity. 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! | |