OK, I have two HTML select elements and a button. I need to disable the button unless both of the selectors have any but default (na) values.
I've got this so far, but it doesn't really work. What am I missing?
JS
function toggleBtn() {
if($(".mySelect").val() == "na") {
$(this).parents("td").find("input:button").attr("disabled", "disabled");
} else {
$(this).parents("td").find("input:button").attr("disabled", "");
}
});
toggleBtn();
$(".mySelect").change(toggleBtn());
HTML
<table>
<tr>
<td>
<select class="mySelect">
<option value="na"></option>
<option value="1">value 1</option>
<option value="2">value 2</option>
</select>
<select class="mySelect">
<option value="na"></option>
<option value="3">value 3</option>
<option value="4">value 4</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="button" value="click me">
</td>
</tr>
</table>