Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using one value in a dropdown list to select another value

Status
Not open for further replies.

Boblevien

Technical User
Nov 3, 2000
38
GB
I am trying to use a dropdown list (which takes it’s values from a database table) to display one value but return another (as in a bound column in Access)

Specifically, I want the user to choose from a list of names but I need to return the email address.

I’ve thought about using the selected name in a second SQL statement to look it up but that seems a little long winded – I don’t want to keep running back to the server.

I can also see how to display and return both the name and the email address but then I can’t see how to disentangle them.

Any ideas would be appreciated
 
Well if you put a PIPE symbol in between them like so
Mary Smith|msmith@doda.com
pipe--------^

Then you can search for the location of the PIPE and break apart the two pieces.

here is the syntax in VBScript for finding a pipe

actually here is a sample.
---------------------------
Dim Pipe As Integer, Name1, Email As String
Pipe = InStr(1, ComboBox, "|")
Name1 = Left(ComboBox, Pipe - 1)
Email = Right(ComboBox, Len(ComboBox) - Pipe - 1)
---------------------------

substitue "ComboBox" above with your combo box'es name


DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
Here's how you do it:
Code:
<select name=&quot;employees&quot;>
  <option value=&quot;<%= oRS(&quot;email&quot;) %>&quot;><%= oRS(&quot;name&quot;) %></option>
</select>
This way the list will show names, but the form will submit their email addresses.


Choo Khor
choo.khor@intelebill.com
 
Hi,

Thanks to you both - the second solution (khorjak's) did actually come to me next day (while thinking about something else) and has to be the right answer for this specific problem but I'm also gratefull for DougP's solution which has so many more applications.

Thanks,

Bob Levien.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top