|
Home > Archive > IIS ASP > August 2006 > Combo Value and Name
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Combo Value and Name
|
|
|
| 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>
| |
| Ray Costanzo [MVP] 2006-08-25, 1:25 pm |
| 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
"Scott" <sbailey@mileslumber.com> wrote in message
news:%231T9t79xGHA.4092@TK2MSFTNGP04.phx.gbl...
> 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>
>
>
>
| |
| Mike Brind 2006-08-25, 7:27 pm |
| 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.
--
Mike Brind
Ray Costanzo [MVP] wrote:[vbcol=seagreen]
> 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
>
>
> "Scott" <sbailey@mileslumber.com> wrote in message
> news:%231T9t79xGHA.4092@TK2MSFTNGP04.phx.gbl...
|
|
|
|
|