I have dropdown list with collection options. When option with certain class is selected I want submit button to be disabled. This is what I've tried to do:
<form id="addToCollection">
<select id="add_to_collection">
<option value="1" class="highlight">1</option>
<option value="2">1</option>
<option value="3">3</option>
</select>
<input id="add-object-to-collection"
type="submit" value="Add" class="button"/>
</form>
<input id="add-object-to-collection" type="submit" value="Add" class="button"/>
if($('#add_to_collection option').hasClass('highlight')) {
$("#add-object-to-collection").prop('disabled', true);
$("#add-object-to-collection").attr('value', 'Added');
} else {
$("#add-object-to-collection").prop('disabled', false);
$("#add-object-to-collection").attr('value', 'Add');
}
So here, when option 1 is selected I want button to be disabled and when other options are selected button be enabled. However here button is disabled for all options.