|
mkov -> Drop down... multiple colums? (3/19/2008 22:29:55)
|
My goal is to populate a drop down with multiple colums from a db table, but only hold a single column as the value. I am using the code found here http://www.frontpagehowto.com/dynamicdrop/dynamicdrop.txt to populate my drop down boxes. I am able to add the mulitple colums/values to the drop down by doing the following when building the options for the drop down: <OPTION><%= objRS("StoreName") %> | <%= objRS("StoreAddress1") %> | <%= objRS("StoreAddress2") %> | <%= objRS("StoreCity") %> | <%= objRS("StoreState") %> | <%= objRS("StoreZip") %></OPTION> This does not seem to me to be the correct way to accomplish what I am looking for. So if someone has any suggestions on the proper way to accomplish it, I am all ears!!! The issue though is that once the user makes a selection, I really only want to hold the StoreName as the value in the drop down, not the address info. Below is the full code for the page... everything else works great on the form. I will be the first to admin this code is probably not the best as I am still learning [:(] Thanks for your help!!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>TSC Entry Portal - Make Selections</title>
</head>
<body>
<div style="position: absolute; width: 124px; height: 105px; z-index: 3; left: 10px; top: 14px; float: left" id="layer3">
<img border="0" src="../images/TSCSolutionslogo.gif" width="116" height="99"></div>
<div style="position: absolute; width: 100%; height: 48px; z-index: 1; left:-23px; top:15px" id="layer1" align="center">
<font size="6" color="#00663F"><b>Entry Portal - Make Selections</b></font><p> </p>
<p align="right"><font color="#00663F">
<a href="EntryPortalDownloadsEmpDoc.asp">Documentation</a> </font>|<font color="#00663F"> <a href="EntryPortalDownloads.asp">
Retailer
Downloads</a></font></div>
<p> </p>
<p> </p>
<p>
<!-- Dynamic Drop Down. A FrontPageHowTo.com ASP Example -->
<!-- Copy and paste this code into a blank page in FP between the body tags
Import the FpNWind.mdb into your web and set up a database connection called Sample to it -->
<!-- Start First Drop Down -->
<%
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.Open Application("EntryPortal_ConnectionString")
Set objRS = objDC.Execute("Select RetailerName FROM tblRetailers")
%>
</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="22%">
</td>
<td width="78%">
<FORM METHOD="POST" NAME="Form1" ACTION="https://www.tscgrpsolutions.com/EntryPortal/EntryPortalSelectNEW.asp">
<p align="left">
<b><font face="Arial" size="2" color="#000000">Choose a Retailer </font></b>
<SELECT NAME="Retailer" SIZE="1" ONCHANGE=Form1.submit()>
<option selected><% = Request.Form("Retailer") %></option>
<%
' Continue until we get to the end of the recordset.
Do Until objRS.EOF
' For each record we create a option tag and set it's value to the countr
%>
<OPTION><%= objRS("RetailerName") %></OPTION>
<%
' Get next record
objRS.MoveNext
Loop
%>
</SELECT></p>
</FORM>
<%
' Close Data Access Objects and free DB variables
objRS.Close
Set objRS = Nothing
objDC.Close
Set objDC = Nothing
%>
<!-- End first Drop Down -->
<!--Second drop down -->
<%
'Some code to hide the second drop down until we make a selection from the first
IF Request.Form("Retailer") = "" Then
Else
'If Country has a value then we get a list of cities for the second drop down
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.Open Application("EntryPortal_ConnectionString")
Set objRS = objDC.Execute("SELECT t_Store_Master.StoreName, t_Store_Master.StoreAddress1, t_Store_Master.StoreAddress2, t_Store_Master.StoreCity, t_Store_Master.StoreState, t_Store_Master.StoreZip FROM tblRetailers INNER JOIN t_Store_Master ON tblRetailers.RetailerID = t_Store_Master.RetailerID WHERE (tblRetailers.RetailerName = '" & Request.Form("Retailer") & "')")
%>
<FORM METHOD="POST" NAME="Form2" ACTION="https://www.tscgrpsolutions.com/EntryPortal/EntryPortalSelectNEW.asp">
<p align="left">
<font face="Arial"><b><font size="2" color="#000000"> Choose a Store </font></b>
<font color="#008080"><b>
<SELECT NAME="StoreName" SIZE="1" ONCHANGE=Form2.submit()>
<option selected><% = Request.Form("StoreName") %></option>
<%
' Continue until we get to the end of the recordset.
Do Until objRS.EOF
' For each record we create a option tag and set it's value to the city
%>
<OPTION><%= objRS("StoreName") %> | <%= objRS("StoreAddress1") %> | <%= objRS("StoreAddress2") %> | <%= objRS("StoreCity") %> | <%= objRS("StoreState") %> | <%= objRS("StoreZip") %></OPTION>
<%
' Get next record
objRS.MoveNext
Loop
%>
<%
'Set a hidden value in the second form for the Country
'so we can pass it along with the city to the next query
%>
</SELECT></b></font><font color="#008080"><b><input type="hidden" name="Retailer" value= "<% = Request.Form("Retailer") %>"></b></font></font></p>
</FORM>
<%
' Close Data Access Objects and free DB variables
objRS.Close
Set objRS = Nothing
objDC.Close
Set objDC = Nothing
End IF
%>
<!--End Second Drop down -->
<!--Third drop down -->
<%
'Some code to hide the second drop down until we make a selection from the first
IF Request.Form("StoreName") = "" Then
Else
'If Country has a value then we get a list of cities for the second drop down
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.Open Application("EntryPortal_ConnectionString")
Set objRS = objDC.Execute("SELECT tblPOGS.POGDesc FROM tblRetailers INNER JOIN tblPOGS ON tblRetailers.RetailerID = tblPOGS.RetailerID WHERE (tblRetailers.RetailerName = '" & Request.Form("Retailer") & "' AND tblPOGS.POGDesc NOT LIke 'Souvenirs%') UNION SELECT 'Souvenirs - Manual Entry' as Bogus FROM tblPOGs UNION SELECT 'Souvenirs - ' + t_Store_Master.StoreState FROM t_Store_Master WHERE (t_Store_Master.StoreName = '" & Request.Form("StoreName") & "')")
%>
<FORM METHOD="POST" NAME="Form3" ACTION="https://www.tscgrpsolutions.com/EntryPortal/EntryPortalSelectNEW.asp">
<p align="left">
<font face="Arial"><b><font size="2" color="#000000"> Choose a POG </font></b>
<font color="#008080"><b>
<SELECT NAME="POGDesc" SIZE="1" ONCHANGE=Form3.submit()>
<option selected><% = Request.Form("POGDesc") %></option>
<%
' Continue until we get to the end of the recordset.
Do Until objRS.EOF
' For each record we create a option tag and set it's value to the city
%>
<OPTION><%= objRS("POGDesc") %></OPTION>
<%
' Get next record
objRS.MoveNext
Loop
%>
<%
'Set a hidden value in the second form for the Country
'so we can pass it along with the city to the next query
%>
</SELECT></b></font><font color="#008080"><b><input type="hidden" name="Retailer" value="<% = Request.Form("Retailer") %>"></b></font></font></p>
</SELECT></b></font><font color="#008080"><b><input type="hidden" name="StoreName" value="<% = Request.Form("StoreName") %>"></b></font></font></p>
</FORM>
<%
' Close Data Access Objects and free DB variables
objRS.Close
Set objRS = Nothing
objDC.Close
Set objDC = Nothing
End IF
%>
<%
'Some code to hide the second drop down until we make a selection from the first
IF Request.Form("POGDesc") = "" Then
Else
IF Request.Form("POGDesc") = "Souvenirs - Manual Entry" Then
%>
<FORM METHOD="POST" NAME="Form4" ACTION="https://www.tscgrpsolutions.com/EntryPortal/EntryPortalSouvenirEntry.asp">
<p align="left">
<font color="#008080" face="Arial"><b>
<input type="button" value="Retreive POG Information" name="B1" onclick=Form4.submit()></b></font></p>
</SELECT></b></font><font color="#008080"><b><input type="hidden" name="Retailer" value="<% = Request.Form("Retailer") %>"></b></font></font></p>
</SELECT></b></font><font color="#008080"><b><input type="hidden" name="StoreName" value= LEFT("<% = Request.Form("StoreName") %>",20)></b></font></font></p>
</SELECT></b></font><font color="#008080"><b><input type="hidden" name="POGDesc" value="<% = Request.Form("POGDesc") %>"></b></font></font></p>
</FORM>
<%
Else
'If Country has a value then we get a list of cities for the second drop down
%>
<FORM METHOD="POST" NAME="Form4" ACTION="https://www.tscgrpsolutions.com/EntryPortal/EntryPortalPOGEntry.asp">
<p align="left">
<font color="#008080" face="Arial"><b>
<input type="button" value="Retreive POG Information" name="B1" onclick=Form4.submit()></b></font></p>
</SELECT></b></font><font color="#008080"><b><input type="hidden" name="Retailer" value="<% = Request.Form("Retailer") %>"></b></font></font></p>
</SELECT></b></font><font color="#008080"><b><input type="hidden" name="StoreName" value="<% = Request.Form("StoreName") %>"></b></font></font></p>
</SELECT></b></font><font color="#008080"><b><input type="hidden" name="POGDesc" value="<% = Request.Form("POGDesc") %>"></b></font></font></p>
</FORM>
<%
End IF
End IF
%>
</body>
</html>
|
|
|
|