Dec 04

jQuery: How to set one <select> element to the value of another (using onchange equivalent)

Tag: JavaScript, Programming, jQueryjs @ 5:33 pm

Say you have an HTML <select> form element and you want to set another <select> element equal to the first one when it changes. Here’s an easy way to do so with jQuery:

$(’#id_of_select1′).change(function() {
    var select1_value = $(this).val();
    $(’#id_of_select2′).val(select1_value);
});

—————-
Now playing: Drexciya - Astronomical Guidepost
via FoxyTunes

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Leave a Reply