SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Aug 27, 2003, 06:52 #1
- Join Date
- Dec 2001
- Location
- Market Harborough, UK
- Posts
- 206
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Changing the selection in a <SELECT> list
Ok,
I've got a page which is part of a book ordering system. On this page, the user can select a book either by Title or ISBN. I have two drop-down <SELECT> menus which are populated with these two lists.
So far so good.
Now, when the user makes a choice from one, I need the other to automatically change to reflect the same choice. I have the onchange() set up ok, but how do I change the currently selected VALUE in the other list? I can easily set it up if I know that I want, say the fifth item selected, but how do I select the correct <OPTION> by value?
As always, TIAPaul Simpson, BSc, MCNI, MCNE
-
Aug 27, 2003, 09:46 #2
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi Paul, gee you seem to be here quite a bit
Is this what you want?
Code:<script type="text/javascript"> <!-- function doit(srcSel, destSel, ndx) { for (i = 0; i < destSel.length; i++) if (srcSel[ndx].value == destSel.options[i].value) destSel.options[i].selected = true; } //--> </script> </head> <body> <form name="myform"> <select name="a" onchange="doit(this, this.form['b'],this.selectedIndex)"> <option value="1" selected>1</option> <option value="21">21</option> <option value="31">31</option> <option value="41">41</option> <option value="51">51</option> <option value="61">61</option> </select> <select name="b" onchange="doit(this, this.form['a'],this.selectedIndex)"> <option value="61" selected>61</option> <option value="31">31</option> <option value="1">1</option> <option value="41">41</option> <option value="21">21</option> <option value="51">51</option> </select>
Where the World Once Stood
the blades of grass
cut me still
-
Aug 28, 2003, 03:17 #3
- Join Date
- Dec 2001
- Location
- Market Harborough, UK
- Posts
- 206
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Indeed you do! Trubble is, you are all just too helpful!
Yep, bang on what I wanted. Thanks.Paul Simpson, BSc, MCNI, MCNE
-
Aug 28, 2003, 06:09 #4
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi Paul,
you are all just too helpful!
Does that mean I can send St. Paul's a bill or get a teaching job there? (I promise not to scare those little English girls with my crusty, old, Brooklynese ways
VinnyWhere the World Once Stood
the blades of grass
cut me still
-
Aug 29, 2003, 06:08 #5
- Join Date
- Dec 2001
- Location
- Market Harborough, UK
- Posts
- 206
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
lol
Paul Simpson, BSc, MCNI, MCNE
Bookmarks