Two combos, one textbox example

This code reads two combos and displays the information along with one text box of values.

Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 38
January 01, 2003
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

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>&nbsp;&nbsp;&nbsp;<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>

blog comments powered by Disqus
DATABASE CODE ARTICLES

- Deployment of the MobiLink Synchronization M...
- MobiLink Synchronization Wizard in SQL Anywh...
- Finding Matching Records in Data Access Pages
- Using the AccessDataSource Control in VS 2005
- A Closer Look at ADO.NET: The Command Object
- A Closer Look at ADO.NET: The Connection Obj...
- Using ADO to Communicate with the Database, ...
- Code Snippets: Counting Records
- Constraints In Microsoft SQL Server 2000
- Multilingual entries into a DB and to be dis...
- Two combos, one textbox example
- ADO Recordset Paging
- SQL Server Database Creator - .NET Version
- Getting A List of Tables From SQL Server
- Discussion & Listserv Module by Mike Eck...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials