SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Location
    .
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question 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.

  2. #2
    American't awestmoreland's Avatar
    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.


    Andy
    From the English nation to a US location.

  3. #3
    SitePoint Enthusiast
    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();
    }
    HTML:
    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

  4. #4
    SitePoint Enthusiast
    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?

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Location
    .
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    podlob, ill be trying your sample too! thanks again!

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep, it will work fine with ASP
    travis

  7. #7
    SitePoint Addict manipura's Avatar
    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

  8. #8
    SitePoint Enthusiast
    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;
    Should be this...
    Code:
    var s = f["menu2[]"];
    here's a link to a multiple dynamic select menu
    travis

  9. #9
    SitePoint Addict manipura's Avatar
    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

  10. #10
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Location
    .
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    ok just wanted to say i got it working with ASP. thanks a bunch guys!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •