Let's say you have the following:
<form method=post action=page2.asp> <select name=foo> <option value='1'>Option 1 <option value='2'>Option 2 </select> </form> |
Many people want to know how to display "Option 1" on the resulting page, in addition to retrieving the value parameter. I have heard of examples where they resorted to a database lookup based on the value, since the SELECT element does not support passing the text, only the value. Here is a decent workaround:
<form method=post action=page2.asp> <select name=foo> <option value='1:Option 1'>Option 1 <option value='2:Option 2'>Option 2 </select> </form> |
Then in the receiving page:
<% foo = Request.Form("foo") foo = split(foo,":") Response.Write "Value was " & foo(0) & "<br>" Response.Write "Display was " & foo(1) %> |
You may want to choose a delimiter other than ":", for example if your text might contain that character. There should always be a character you can choose as a delimiter that has little to no chance of ever being inside the string.