Combo Value and Name

S

Scott

If I click the "Update" button on my form below, I can retrieve the value of
my combo by using code in the FORM RESULTS section below. Therefore, if I
choose the "Inside" option in my combo, I would get "1" as the value of my
combo box.

Is there any way to retrieve the Name associated with the value? So not only
retrieve the combo value of 1, but also retrieve the name "Inside" after
submitting my form?



FORM RESULTS **********************

cboMachineArea=Request.Form("cboMachineArea")


FORM CODE ************************

<form name="DataForm" method=post action="form_test.asp">

<font face="Verdana,sans-serif" size="2">Name</font><br>

<input type="textbox" size=30 name="Full Name" value="My Test Name"><br>
<font face="Verdana,sans-serif" size="2">Area</font><br>
<select name="cboArea" id="cboArea">
<OPTION value="1" selected>Inside</option>
<OPTION value="2">Outside</option>
</select>

<br>
<input type=submit name="DataFormSubmit" value="Update">
</form>
 
R

Ray Costanzo [MVP]

No, browser don't post that data back to the server. Either look the text
value back up from the same source you used to generate the dropdown box in
the first page, or include the text value in the option value and parse it
out.

<select name="cboArea">
<option value="1,Inside">1</option>
<option value="2,Outside">2</option>
</select>


<%

Dim aParts
aParts = Split(Request.Form("cboArea"), ",")

Response.Write "ID value = " & aParts(0) & "<hr>"
Response.Write "Text value = " & aParts(1)

%>

Ray at work
 
M

Mike Brind

Or, if that really is the select group's options and ithey will never
change, drop the value altogether. It doesn't seem to serve any
purpose in this example:

<select name="cboArea">
<option>Inside</option>
<option>Outside</option>
</select>

Ray's suggestions are the best option (no pun intended) for lists that
may change or ones that are generated dynamically.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,263
Messages
2,571,062
Members
48,769
Latest member
Clifft

Latest Threads

Top