Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - can i put more than one Value in an Selec
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic Closedcan i put more than one Value in an Selec

 Post Reply Post Reply
Author
zMaestro View Drop Down
Senior Member
Senior Member


Joined: 11 May 2003
Location: Egypt
Status: Offline
Points: 1183
Direct Link To This Post Topic: can i put more than one Value in an Selec
    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.

Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Direct Link To This Post 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.

Back to Top
Bluefrog View Drop Down
Senior Member
Senior Member


Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
Direct Link To This Post 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.

 

Back to Top
zMaestro View Drop Down
Senior Member
Senior Member


Joined: 11 May 2003
Location: Egypt
Status: Offline
Points: 1183
Direct Link To This Post 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$ashraf@egyvision.com">Name</option>
<Option value="19$Ashraf Gomaa$ashrafvision@egydsl.com"> Ashraf Gomaa</option>
<Option value="28$Britney White$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 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

 



Edited by zMaestro
Back to Top
Bluefrog View Drop Down
Senior Member
Senior Member


Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
Direct Link To This Post Posted: 29 June 2003 at 9:14am
Great. Good to hear it helped you out.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.