|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Drop-Down Display vs. Value
There must be a way.
I'm making a selection from a drop-down list that had an ID number as the value and displays a text field. After submitting the data to the database I am sending an email and would like to include the value displayed in the DD box, not the hidden value. How so I reference that displayed value? <select name="select"> <option value="1">Blue</option> <option value="2">Red</option> <option value="3">Green</option> </select> I want to use the number for the database but display the words in the confirmation email. Is thsi possible without making another roundtrip to the database? <bryan.***@gmail.com> wrote in message
Show quote news:1141872218.332309.39960@i39g2000cwa.googlegroups.com... document.forms[0].select.options[document.forms[0].select.selectedIndex].tex> There must be a way. > I'm making a selection from a drop-down list that had an ID number as > the value and displays a text field. After submitting the data to the > database I am sending an email and would like to include the value > displayed in the DD box, not the hidden value. How so I reference that > displayed value? > <select name="select"> > <option value="1">Blue</option> > <option value="2">Red</option> > <option value="3">Green</option> > </select> > > I want to use the number for the database but display the words in the > confirmation email. Is thsi possible without making another roundtrip > to the database? t; I appreciate the reply but I just get an error. The DD list I'm using
is called selHomeID. var HomeAddress = document.forms[0].selHomeID.options[document.forms[0].selHomeID.selectedIndex].text; Can you explain this a little and how I should be using it. <bryan.***@gmail.com> wrote in message
news:1141878756.070242.193600@i40g2000cwc.googlegroups.com... document.forms[0].selHomeID.options[document.forms[0].selHomeID.selectedInde> I appreciate the reply but I just get an error. The DD list I'm using > is called selHomeID. > var HomeAddress = > x].text; > What error? Try this "as-is".> Can you explain this a little and how I should be using it. > <html> <head> <title>selHomeID.htm</title> <script type="text/javascript"> function HomeID() { var form = document.form1; var pick = form.selHomeID.selectedIndex; var HomeAddress = form.selHomeID.options[pick].text; alert(HomeAddress); } </script> </head> <body> <form name="form1"> <select name="selHomeID"> <option value="1">Blue</option> <option value="2">Red</option> <option value="3">Green</option> </select> <input type="button" value="HomeID" onclick="HomeID()"> </form> </body> </html> bryan.***@gmail.com wrote:
Show quote > There must be a way. I assume you are talking about doing this in server-side code. If so, there > I'm making a selection from a drop-down list that had an ID number as > the value and displays a text field. After submitting the data to the > database I am sending an email and would like to include the value > displayed in the DD box, not the hidden value. How so I reference that > displayed value? > <select name="select"> > <option value="1">Blue</option> > <option value="2">Red</option> > <option value="3">Green</option> > </select> > > I want to use the number for the database but display the words in the > confirmation email. Is thsi possible without making another roundtrip > to the database? is really no way to directly read the display value from the Request: only the values are sent via Request which you have already discovered. Yes, you could make another trip to the database to retrieve the value, but that really is not necessary. There are several options: 1. Use client-side code to store the text of the selected option in a hidden field. 2. You could store the value-text list used to create the options in a session variable, perhaps using an xml document, and then simply look up the text using the value received from Request via an XPath query usnig selectSingleNode. 3. Or, if you could, when you originally build the options, disconnect the recordset from the database, use its Save method to save it as xml and either save it to a file or to a session variable, thenwhen processing the request, open a new recordset using the xml-persisted recordset as the source. Think about it and decide which route you wish to take. If you decide on the first option and need help implementing it, you should move this conversation to a client-side scripting group such as microsoft.public.scripting.jscript. Otherwise, get back to us for help with either of the other two options. Bob Barrows -- Microsoft MVP - ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM"
Show quote
"bryan.***@gmail.com" <bryan.***@gmail.com> wrote: You could make the "values" compound, something like this:>There must be a way. >I'm making a selection from a drop-down list that had an ID number as >the value and displays a text field. After submitting the data to the >database I am sending an email and would like to include the value >displayed in the DD box, not the hidden value. How so I reference that >displayed value? ><select name="select"> > <option value="1">Blue</option> > <option value="2">Red</option> > <option value="3">Green</option> > </select> > >I want to use the number for the database but display the words in the >confirmation email. Is thsi possible without making another roundtrip >to the database? <option value="1;blue">Blue</option> <option value="2;red">Red</option> <option value="3;green">Green</option> Then use the "split" function to break the returned value into its component parts. Now you have both the number and the string. -- Tim Slattery MS MVP(DTS) Slatter***@bls.gov |
|||||||||||||||||||||||