View Single Post
Old 03-18-2009, 05:39 AM   #7 (permalink)
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, I see what you mean. Could reproduce it on a Bold device. This is a bug for me. The state/value of the checkbox is set AFTER the onClick action is executed, that's why you get wrong value if you checks the state of the chkSelectAll checkbox.
It seems to be fixed in 4.6.1

you could use a global variable to save the state a an additional hidden field in your form.

here is the version with toggling the global variable:
Code:
<html>
<head>
<title>
check/uncheck all
</title>

</head>
<body>

<SCRIPT LANGUAGE="JavaScript">
    var allChecked = false;

    function chkAllFunc(frm)
    {
	allChecked = !allChecked;

       for(i=0; i<frm.elements.length; i++)
       {
           var alertText = "called";                
            if(frm.elements[i].type == "checkbox"){
                if(frm.elements[i].name!="chkSelectAll")
                {            
                    frm.elements[i].checked=allChecked; 
                }
              }
       }
       //alert(alertText)
   }
</script>



<form name="frmStatus">
    <input type="checkbox" name="list" value="1">1<br>
    <input type="checkbox" name="list" value="2">2<br>
    <input type="checkbox" name="list" value="3">3<br>
    <input type="checkbox" name="list" value="4">4<br>
    <input type="checkbox" name="list" value="5">5<br>
    <br>
    <input type="checkbox" name="chkSelectAll" value="Check All" onClick="chkAllFunc(this.form);"> All
    <br>
</form>
</body>
</html>
__________________
Blessed is the end user who expects nothing, for he/she will not be disappointed. (Franklin's Rule)

Last edited by Ivanov : 03-18-2009 at 05:40 AM.
Offline   Reply With Quote