Combo and textbox example

Adrian Forbes shares a Combo and Textbox Example

Contributed by
Rating: 3 stars3 stars3 stars3 stars3 stars / 15
January 01, 2003
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

 

This has a combo with a number attached to it. Same as 2Combo1Textbox with just the secondary combo and textbox. Selecting a value in the combo will update the textbox with the associated number.


Here is the code for this Example

<!-- 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, intValue from Parents", strconn
if Request("cboPrimary") = "" then
lPrimary = objRS("ID")
else
lPrimary = clng(Request("cboPrimary"))
end if
%>
<form name=frmTest action="ComboTextboxLinked.asp" method=POST>
<p>
<select name=cboPrimary size=1 onChange="PopulateTextbox();">
<%while not objRS.EOF
lID = clng(objRS("ID"))%>
<option value="<%=lID%>"<%if lPrimary = lID then Response.Write " SELECTED"%>>
<%=objRS("strParent")%>
<% objRS.MoveNext
wend
%>
</select>&nbsp;&nbsp;&nbsp;<input type=TEXT name=txtValue>
</p>
<p>
<input type=SUBMIT value="Select" id=SUBMIT1 name=SUBMIT1>
</p>
</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
%>
<script language=VBScript>
sub window_onLoad
PopulateTextbox
end sub

sub PopulateTextbox
lID = document.frmTest.cboPrimary.value
document.frmTest.txtValue.value = document.all("intValue" & lID).value
end sub
</script>

blog comments powered by Disqus
ASP.NET ARTICLES

- Implementing ASP.NET 4.0 Page.MetaDescriptio...
- ASP.Net Development Tips
- Intro to Sessions in ASP.Net
- Google Maps API Introduction in ASP.NET usin...
- Creating an ASP.NET 3.5 Gridview Image Galle...
- Encrypt QueryString in ASP.NET 3.5 using VB....
- ASP.NET 3.5 Drop Down List Controls
- Connect to Access Database with ASP.Net
- Secure Audio Streaming with ASP.Net and Flash
- Dynamic Sitemap and Navigation in ASP.Net
- Implement Gzip and Deflate Compression in AS...
- Run ASP.Net in Ubuntu with Apache
- ASP.Net Mono Website Contact Forms
- ASP.Net URL Rewriting Methods
- Murach`s ASP.NET 4 Web Programming with C# 2...

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 6 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials