Print Page | Close Window

can i put more than one Value in an Selec

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Web Design Discussion
Forum Description: Discussion on web design and development subjects.
URL: https://forums.webwiz.net/forum_posts.asp?TID=3757
Printed Date: 28 March 2026 at 11:59pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: can i put more than one Value in an Selec
Posted By: zMaestro
Subject: can i put more than one Value in an Selec
Date Posted: 23 June 2003 at 6:54am

.. i.e.

a normal select tag is like this:
<Option Value="Name">Name</Option>

I have 3 text boxes, 1st for ID, 2nd for FirstName, 3rd for LastName,
I have a database created select box which contains about 10 records...
each record is like this:
"<option value=" & r("ID") & ">" & r("FirstName") & " " & r("LastName") & "</option>"

when i choose one of these items, i want to automatically fill the 3 boxes with the records ID, FirstName, LastName

I do this using JavaScript...
 document.Form.Box1.value = document.DataBase.Select.value

(where DataBase is the name of the form containing the 3 text boxes)

here the value will be written as the ID, so the Value of the 1st text box will be the "ID"

for text box 2 and 3, how can i put the other data (FirstName and LastName),

I tried this but didn't work:
 document.Form.Box2.value = document.DataBase.Select.text

I also tried this but didn't work too...
"<option first=" & r("FirstName") & " last=" & r("LastName") & " value=" & r("ID") & ">" & r("FirstName") & " " & r("LastName") & "</option>"
 document.Form.Box1.value = document.DataBase.Select.value
 document.Form.Box2.value = document.DataBase.Select.first
 document.Form.Box3.value = document.DataBase.Select.last

Is there a way of doing so?
Thanks.




Replies:
Posted By: KCWebMonkey
Date Posted: 23 June 2003 at 7:26am

A select option can only have one value. You will need to find another way to do this.



Posted By: Bluefrog
Date Posted: 23 June 2003 at 7:51am

I've done something similar before. However, I just delimit the value with something that cannot appear in there. In my particular situation, all values were alphanumeric, so I used a dollar sign '$' to do it. e.g.

<option value="1$John$Leprechaun">etc.etc.etc...

Then, you can just split on the $ and get your values out again.

Here again:

<SELECT onchange=changePage(this.value); name=modify> <OPTION value="" selected>[MODIFY]</OPTION>
<OPTION value=EN$148>My text 1</OPTION>

...

<SCRIPT language=JavaScript>
 function changePage(theValue) {
    var theSplit = theValue.split("$");
    window.location.href=thePage.asp?ModIns=Modify&OurLanguage='+theSplit[0]+'&theIdx=' + theSplit[1];
 }
</SCRIPT>

Your situation is a bit different, but I'm sure you can go from there - Just recreate the entire value with delimiters and then do

document.Form.Box1.value = document.DataBase.Select.value

Hope that helps.

 



Posted By: zMaestro
Date Posted: 23 June 2003 at 3:13pm

Thanks... it worked ...

<SCRIPT language=JavaScript>
 function changePage(theValue,$) {
    var theSplit = theValue.split("$");
    document.egyGen.ID.value = ''+theSplit[0]+''
    document.egyGen.Name.value = ''+theSplit[1]+''
    document.egyGen.Email.value = ''+theSplit[2]+''
    }
</SCRIPT>

<Form action="" Name="Data">
<Select Name="SelectName" onChange="changePage(this.value);">
<Option>Choose Name</Option>
<Option value="15$Name2$mailto:15$Name2$ashraf@egyvision.com">Name2'>ashraf@egyvision.com">Name</option>
<Option value="19$Ashraf Gomaa$mailto:Gomaa$ashrafvision@egydsl.com">'>ashrafvision@egydsl.com"> Ashraf Gomaa</option>
<Option value="28$Britney White$mailto:White$vision@egyasp.com">Britney'>vision@egyasp.com">Britney White</option>
</Select></Form>

<Form action="" name="egyGen" Method="Post">
<input readonly type="text" name="ID" size="20">
<input readonly type="text" name="Name" size="20">
<input readonly type="text" name="Email" size="20">
</Form>

Now, when I select the name Ashraf Gomaa from the select menu,
the value 19 (ID) will be written in the first text box.
the value Ashraf Gomaa (Name) will be written in the second text box.
the value mailto:ashrafvision@egydsl.com - ashrafvision@egydsl.com (Email) will be written in the third text box.

just by selecting the name from the drop down menu.... which is exactly what i asked for...
thanks all for your help

 



Posted By: Bluefrog
Date Posted: 29 June 2003 at 9:14am
Great. Good to hear it helped you out.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net