|
Hi All,
I have a screen on which checkboxes are displayed dynamically. I do not have any control on how many would be there. The default label on the button is SELECT ALL. Once I click it all checkboxes are checked. The label at that point changes to UNSELECT ALL. If I click on the button now (UNSELECT ALL), all the checkboxes are unchecked. Following code accomplishes that funcationality.
However, I need to make a further enhancement to this code.
1. User clicks on SELECT ALL
2. All checkboxes are selected
3. User unchecks one or more of the boxes.
4. Label should not be SELECT ALL anymore.
(Since one or more checkboxes are unchecked)
Any help with this would be greatly appreciated.
Thank you,
William H. Andruss.
Here is the button syntax:
=========================
<TD>
<input type="button" class="ApScrnButton" onmouseover="if(!this.disabled){this.className='Ap
ScrnButtonHover';}"
onmouseout="if(!this.disabled){this.className='ApScrnButton';}" value="SELECT ALL" id="myButton1" onClick="javascript:changeAll()"></input>
</TD>
Here is the underlying javascript:
=================================
function changeAll() {
if (document.form.myButton1.value == "SELECT ALL") {
i = 0;
tmpstr = "";
count = document.form.elements.length;
while (i < count) {
tmpstr = document.form.elements.name.split("UserId_");
if (document.form.elements.type == "checkbox"
&& tmpstr.length == 2) {
document.form.elements.checked = true;
document.form.myButton1.value = "UNSELECT ALL";
}
i++;
}
}
else {
i = 0;
tmpstr = "";
count = document.form.elements.length;
while (i < count) {
tmpstr = document.form.elements.name.split("UserId_");
if (document.form.elements.type == "checkbox"
&& tmpstr.length == 2
&& document.form.elements.id != 1) {
document.form.elements.checked = false;
document.form.myButton1.value = "SELECT ALL";
}
i++;
}
}
}
|
|
|
|
|
|
|
// |