i have several array checkbox, 1 submit button and 1 dropdown menu
how can i disable/enable this submit button and dropdown menu when 1 or many checkbox is checked.
when this submit button is disable and user click on it, dialog box appear tell no checkbox is checked
something like this : http://jsfiddle.net/frantic912/3YbZu/
setButton(buttonGroup) {
var retArr = new Array();
if (buttonGroup[0]) {
for (var i = 0; i < buttonGroup.length; i++) {
if (buttonGroup[i].checked) {
document.frm_search.send.disabled = true;
alert('Please check the first checkbox!');
}
}
}
}
<form method="post" name="frm_search">
<table>
<tr>
<td align="center">
<input type="checkbox" name="appr[]" id="appr" value="<?php echo $row['userID']; ?>" onclick="setButton(this);"/>
</td>
</tr>
<tr>
<td>bla bla bla</td>
</tr>
<tr>
<td>
<select name="slct_appr" id="slct_appr" >
<option value="1">-- Please Choose --</option>
<option value="2">Approve</option>
<option value="3">None</option>
</select>
</td>
</tr>
<tr>
<td align="center">
<input name="submit" class="submit" id="send" type="submit" value="send" />
<input name="txt_action" type="hidden" id="txt_action" value="frm_add_submit" />
</td>
</tr>
</table>
</form>
As per my understanding you requirement is like this. Please check the DEMO and let me know if its fine to you.
DESCRIPTION
In above code on every click I am checking the length of check box if its greater than 0 then we are allowing to submit the from else we are not allowing to submit the from and making same time disabled of submit button.
There is few changes in HTML markup as well like this
On page load I disabled the select box and button to initial page submit.