SitePoint Sponsor |
|
User Tag List
Results 1 to 10 of 10
Thread: 2 drop down menus which interact
-
Feb 6, 2003, 01:56 #1
- Join Date
- Oct 2002
- Location
- .
- Posts
- 49
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
2 drop down menus which interact
hello,i dont know if this has been answered but ive been searchin all over the net for this.
what i want to happen is something like this autolink.ph
check out the 2 drop down menus on the top left, how do i do that? uhm thats it...im a newbie on this sorry.
-
Feb 6, 2003, 04:18 #2
- Join Date
- Sep 2002
- Location
- Grand Rapids, MI
- Posts
- 1,168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
There's a lot to take in here, but I think that this is basically what you want: SPF Thread. It's all about arrays really.
AndyFrom the English nation to a US location.
-
Feb 6, 2003, 18:45 #3
- Join Date
- Nov 2002
- Posts
- 51
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
here's a simple way to do it...
See this code work
Javascript:
Code:function changeSelect(select){ var selectValue = select.options[select.selectedIndex].value; if(selectValue == "") return; var f = select.form;// a reference to the form var s = f.menu2;// a reference to the select menu to modify s.options.length = 0;// clear any options from this select menu switch(selectValue){ case "option1": s.options[0] = new Option("Option 1-1", "value1-1"); s.options[1] = new Option("Option 1-2", "value1-2"); s.options[2] = new Option("Option 1-3", "value1-3"); break; case "option2": s.options[0] = new Option("Option 2-1", "value2-1"); s.options[1] = new Option("Option 2-2", "value2-2"); s.options[2] = new Option("Option 2-3", "value2-3"); s.options[3] = new Option("Option 2-4", "value2-4"); break; case "option3": s.options[0] = new Option("Option 3-1", "value3-1"); s.options[1] = new Option("Option 3-2", "value3-2"); } s.focus(); }
Code:<form> <select name="menu1" onchange="changeSelect(this)"> <option value="">Select an Option</option> <option value="option1">Option 1</option> <option value="option2">Option 2</option> <option value="option3">Option 3</option> </select> <select name="menu2"> </select> </form>
travis
-
Feb 6, 2003, 18:55 #4
- Join Date
- Oct 2002
- Location
- .
- Posts
- 49
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
hey great thanks! this will work with ASP right? i mean just saving the values into a variable?
-
Feb 6, 2003, 18:59 #5
- Join Date
- Oct 2002
- Location
- .
- Posts
- 49
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
podlob, ill be trying your sample too! thanks again!
-
Feb 6, 2003, 19:24 #6
- Join Date
- Nov 2002
- Posts
- 51
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
yep, it will work fine with ASP
travis
-
Feb 7, 2003, 17:56 #7
- Join Date
- Apr 2001
- Location
- Calgary,AB
- Posts
- 345
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
One question about the above script....
When I run menu2 as a multiple select, and in order for it
to return as an array on the next page I put a "[]" at the end
of menu2. I also change the name of the select in the J.S. to
the same thing. But it doesn't work.
I'm working with PHP and I want to be able to select Multiples
on either menu, but the 2nd is better than 1st
-
Feb 7, 2003, 18:23 #8
- Join Date
- Nov 2002
- Posts
- 51
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You have to use the forms array to do that.
This...
Code:var s = f.menu2;
Code:var s = f["menu2[]"];
travis
-
Feb 7, 2003, 18:29 #9
- Join Date
- Apr 2001
- Location
- Calgary,AB
- Posts
- 345
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Exactly what I was looking for. Thanks!
Now I can go home
-
Feb 10, 2003, 02:03 #10
- Join Date
- Oct 2002
- Location
- .
- Posts
- 49
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ok just wanted to say i got it working with ASP. thanks a bunch guys!
Bookmarks