0

having issue with my TWO dropdowns, not displaying the specific values based on the selection of the first box. Currently all values display regardless of which first option is selected.

I am currently using Jquery 1.6 with the actual code. See Demo here

Here is a example of my HTML.

<select name="column_select" id="column_select">
<option id="1" value="/search_option_1">First</option>
<option id="2" value="/search_option_2">Second</option>
<option id="3" value="/search_option_3">Third</option>
</select>

<select name="layout_select" id="layout_select">

<!-- Child options from Parent Option 1 -->
<option id="1" value="/first_value/one">1.1</option>
<option id="1" value="/first_value/two">1.2</option>

<!-- Child options from Parent Option 2 -->
<option id="2" value="/second_value/one">2.1</option>
<option id="2" value="/second_value/two">2.2</option>

<!-- Child options from Parent Option 3 -->
<option id="3" value="/third_value/one">3.1</option>
<option id="3" value="/third_value/two">3.2</option>
</select>

Now as you can see im using the id="" to be able to reference which options go with which first selection box. Im doing this because i need to specify specific values for each option. See the demo code for more insight and what im trying to accomplish.

Thanks

6
  • ID's must be unique, or else the HTML won't be valid, FYI :D Commented Aug 26, 2013 at 22:03
  • @tymeJV Yeah i know this, im just unsure how to link these options with the right parent option. and still have different values for each option. Commented Aug 26, 2013 at 22:09
  • You can always use an instance of this, however both of your selects have ID's, so I believe @Ringo's answer will work just fine. Commented Aug 26, 2013 at 22:15
  • I realize now what you might be trying to do is show different options in the second select box depending on which option is selected in the first select box. Is this true? Commented Aug 26, 2013 at 22:33
  • @Ringo You are exactly correct Commented Aug 27, 2013 at 2:37

1 Answer 1

2
$(document).ready(function() {
    $('#multi_select').click(function() {
      var url = 'http://www.urlimusing.com/' + $('#column_select').val() + $('#layout_select').val();
      window.location = url;
    });
});

Everything else in your existing document ready looks weird and bad. Just throw those lines away.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.