Onchange - dropdown list selected using jquery

I have a drop-down list in the header, and no matter what value is selected in the header, it should reflect the same in the drop-down list of details, how do I do this? any conclusions?

$("#myddl").change(function()
{ 
     //update all the dropdown list...  
});

http://jsfiddle.net/abuhamzah/4QvfP/

  Header:
    <br />
    <select id="myddl" name="myddl">
        <option value="1">One</option>
        <option value="2">Twooo</option>
        <option value="3">Three</option>
    </select>
    <p>Detail</p>
        <br />
    <select id="Select1" name="myddl">
        <option value="1">One</option>
        <option value="2">Twooo</option>
        <option value="3">Three</option>
    </select>
    <br />
    <select id="Select2" name="myddl">
        <option value="1">One</option>
        <option value="2">Twooo</option>
        <option value="3">Three</option>
    </select>
    <br />
    <select id="Select3" name="myddl">
        <option value="1">One</option>
        <option value="2">Twooo</option>
        <option value="3">Three</option>
    </select>
    <br />
    <select id="Select4" name="myddl">
        <option value="1">One</option>
        <option value="2">Twooo</option>
        <option value="3">Three</option>
    </select>
    <br />
    <select id="Select5" name="myddl">
        <option value="1">One</option>
        <option value="2">Twooo</option>
        <option value="3">Three</option>
    </select>
+5
source share
5 answers

Something in this direction will work. It wraps your “Details” in a container to make the choice a little easier.

http://jsfiddle.net/qMXSR/2/

$("#myddl").change(function()
{ 
     $('.detail').find('select').val($(this).val());
});​
+4
source

$.on "change". select, id select - . () .

​$("#myddl").on("change", function(o){
   $("select[id^=Select]").val(o.target.value);
});​​​​​​​​​​
+2

This code will do this:

$(document).ready(function()
{
    $("#myddl").live('change', function()
    {
        $("#Select1, #Select2, #Select3, #Select4, #Select5").val($(this).val());
    });
});

Updated JS Fiddle is here: http://jsfiddle.net/leniel/4QvfP/7/

+1
source
​$(function(){
    $('#myddl').change(function(){
        var value = $(this).val();
        $('select[name=myddl] option[value='+value+']').attr('selected', 'selected');
    });
})​
+1
source

In the onchange of the first dropdown menu, you can jQuery select other dropdown lists and use .each () to iterate and set other parameters.

0
source

All Articles