jquery - How do I disable select option fields when I select a previous option? -


i have 2 select boxes, 1 choose amplifier , second choose cabinet matches it.

my problem need add value of disabled="disabled" cabinet options if 'amplifier 2' selected.

i have tried few options such as:

$("#amp option.grey-out option:selected").change() {     $("option.disable").attr("select[disabled='disabled']"); }); 

here's html:

<select required="" autofocus="" id="amp" name="options" class="select-model">     <option data-value="500">amplifier 1</option>     <option data-value="1000" class="grey-out">amplifier 2</option> </select>  <select required="" autofocus="" id="cab" name="options" class="select-model">     <option data-value="100" class="disable">cabinet 1</option>     <option data-value="200" class="disable">cabinet 2</option> </select> 

i have started jsfiddle here

looks need that:

$("#amp").on('change', function () {    $("#cab").prop('disabled', $(this).val() == "amplifier 2") }); 

http://jsfiddle.net/gvalmon/shgfk/

more details in question may find better solution.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -