Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Drop-Down Display vs. Value

Reply
Thread Tools

Drop-Down Display vs. Value

 
 
bryan.com@gmail.com
Guest
Posts: n/a
 
      03-09-2006
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?

 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      03-09-2006
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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?



document.forms[0].select.options[document.forms[0].select.selectedIndex].tex
t;


 
Reply With Quote
 
 
 
 
bryan.com@gmail.com
Guest
Posts: n/a
 
      03-09-2006
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.

 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      03-09-2006
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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.selectedInde
x].text;
>
> Can you explain this a little and how I should be using it.
>


What error? Try this "as-is".

<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>


 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      03-09-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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?


I assume you are talking about doing this in server-side code. If so, there
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"


 
Reply With Quote
 
Tim Slattery
Guest
Posts: n/a
 
      03-09-2006
"(E-Mail Removed)" <(E-Mail Removed)> wrote:

>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?


You could make the "values" compound, something like this:

<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)
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display byte array back to pdf and display in IE SG Java 6 01-15-2008 01:02 PM
Loop Form - extract display 'value' as well as form value? ASP General 2 02-20-2006 09:36 PM
choosing to display or not to display a checkbox in repeater control. Imran Aziz ASP .Net 4 08-11-2005 05:00 PM
Double double display display problem problem Tom Accuosti Firefox 3 09-27-2004 10:02 PM
Display and display model Marc Twain Java 1 01-13-2004 07:05 PM



Advertisments