| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Multiple Values from single Drop Down Selections.
Hi,
Hope you're all well. Problem: - Environment ASP/VB/IIS/SQL Server - I have a drop down menu that is populated using a DB query. - The DB Query returns two values that constructs the drop down. - An ID which is used for the value="" of the option tag - A Name which is Displayed on the browser's drop down selection list. Code:
Response.Write "<OPTION value='"
Response.Write Session("RS")("ID") & "'"
Response.Write ">"
Response.Write Session("RS") ("NAME")
Response.Write "</OPTION>"
Session("RS").MoveNext
The output looks something like this: Code:
<SELECT name="NAMEZ"> <OPTION value='119'>Jack</OPTION> <OPTION value='120'>Mack</OPTION> <OPTION value='175'>Raq</OPTION> <OPTION value='174'>Crack</OPTION> </SELECT> The selected option is posted through an HTML form through to a Results.asp page where various operations take place. Now, there is a requirement that Results.asp has to display the Parameters at the top of the Page, and believe it or not the drop downs are included. Code:
Request.Form("NAMEZ")
Will return an ID. Unfortunatly, its meaningless to the end user. I've searched around for a few days, and could not find an easy way to grab the contents between the <option></option> tags, and have been thinking of going through desperate measures: Desperate Measure 1: Code:
Response.Write "<OPTION value='"
Response.Write Session("RS")("ID") & "XXX" & Session("RS") ("NAME") & "'"
Response.Write ">"
Response.Write Session("RS") ("NAME")
Response.Write "</OPTION>"
Session("RS").MoveNext
Whereby, on Results.asp following a: Code:
Request.Form("NAMEZ")
I will perform a split operation by and splitting the NAMEZ value into an Array Code:
arrayNamez = Split(Request.Form("NAMEZ"),"XXX")
Desperate Measure 2: - onSelect of an item in the drop down, the form is submitted to the same page. - on the Second Load of the .asp page a Database query will store both ID and Names into Hidden form variables. Desperate Measure 3: - A DB query is performed on Results.asp to re - retrieve the NAME from the DB. Conclusions: On what the best approach is, as well as alterantives are welcome. Many thanks for reading. |
|
#2
|
||||
|
||||
|
I myself have had no problems with desperate measures 1 or 3. I think they are both good ways of doing what you want it to do. I'm more favorable for measure one. In my opinion, it takes less time for me to insert that little bit of code rather than doing a whole new query on the results page to get the same result. Just my opinion though.
![]() |
|
#3
|
|||
|
|||
|
cheers,
needed a second opinion just incase there was an easier way. gone for measure one.. dont seem so desperate now ![]() |
![]() |
| Viewing: ASP Free Forums > Web Design > Web Layout > Multiple Values from single Drop Down Selections. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|