Click here to Skip to main content
15,902,763 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

Please check the code below it's working properly in IE but not working in Mozila.

The scenario is that my checkboxlist lidt databound from code behind.
If user selects the first item of the list he is not able to select any other and others will disbaled. Now if user selects any other, ha can not select the first, it will be disabled automatically.

And as and when user uncheck the checkboxes it enables the disbaled all.

I have done it and it;s working in IE please tell me that what i have to do to make it work in Mozila and others also.

A fast reply is awaited!

The code is as :
Java
//To Enable and Disable check boxes of worker status
    function UnCheckAll() {
        if (document.getElementById("cblStatus").cells.innerText != "") {
            //Get the checkboxlist object 
            var checkBoxList = document.getElementById("cblStatus");
            //Get the number of checkboxes in the checkboxlist 
            var numCheckBoxItems = checkBoxList.cells.length;
            if (document.getElementById(checkBoxList.id + '_' + [0]).checked == true) {
                for (i = 1; i < numCheckBoxItems; i++) {
                    //Get the checkboxlist item 
                    var checkBox = document.getElementById(checkBoxList.id + '_' + [i]);
                    //Check if the checkboxlist item exists, and if it is checked
                    checkBox.checked = false;
                    checkBox.disabled = true;
                }
            }
            else {
                for (i = 1; i < numCheckBoxItems; i++) {
                    //Get the checkboxlist item 
                    var checkBox = document.getElementById(checkBoxList.id + '_' + [i]);
                    //Check if the checkboxlist item exists, and if it is checked
                    checkBox.disabled = false;
                }
                document.getElementById(checkBoxList.id + '_' + [0]).checked = false;
                document.getElementById(checkBoxList.id + '_' + [0]).disabled = true;
            }
            //Enable sourced now
            if (EnableSourced(numCheckBoxItems, checkBoxList)) {
                document.getElementById(checkBoxList.id + '_' + [0]).disabled = false;
            }          
        }
    }
//To enable sourced checkbox
    function EnableSourced(numCheckBoxItems, checkBoxList) {
        var RETVAL = false;
        for (i = 1; i < numCheckBoxItems; i++) {
            //Get the checkboxlist item 
            var checkBox = document.getElementById(checkBoxList.id + '_' + [i]);
            if (checkBox.checked == true) {
                return false;
            }
            else {
                RETVAL = true;
            }
        }
        return RETVAL;
    }



Please check the code is there any change required to run it in Mozila............


Any one who can help me please.........Thanx in advance...........

Any one please help me................


Ok any one don't know how to make it???????????
I am totally frustated with this code any guy please help. It's really needed. I don't like JavaScript. Because of it's not a standard language, any how i was able to write the above code and it's working in IE but not in Mozila. Please try to solve this issue.

Please make it solve!!!!!!!!!!!!
?????????????????????????????

?????????????????????
\


???

Please help!!!!!!!!!!!!


??? I am not aware of Firebug please make it solve?????????


Any one please help me how can i find the total items in listbox in mozila? AND THEN CHECK FOR IT'S CHECKED PROPERTY?
PLEASE HELPPPPPPPPPPP!!!!!!!!!!!!!!!11

SQL
Any one please help me how can i find the total items in listbox in mozila? AND THEN CHECK FOR IT'S CHECKED PROPERTY?
PLEASE HELPPPPPPPPPPP!!!!!!!!!!!!!!!11
Posted
Updated 21-Nov-11 0:59am
v15
Comments
Gopal Krishna Ranjan 21-Nov-11 2:39am    
Any one Please answer me!!!!!!!!!
Gopal Krishna Ranjan 21-Nov-11 3:09am    
Is there any equivalent code which will work in all browsers!!!!!!!!!!!!1
raju melveetilpurayil 21-Nov-11 6:33am    
use debugger, Firebug for FF

I don't have time to test this code, but the method of sorting this out is this: catch all exceptions on a very top of stack frame and analyze exception information when caught. Find out in which line the exception is thrown. Chances are, some method/property is not implemented in Mozilla. Avoid using this incompatible method/property through a work-around using only the standard methods/properties, which is usually possible.

Alternatively, run it under JavaScript debugger. If you use Visual Studio, it's easy to do.

Sorry for incomplete solution, but I hope you can sort it out by yourself.

—SA
 
Share this answer
 
Comments
Gopal Krishna Ranjan 21-Nov-11 2:44am    
The code is working in IE fine but not working in Firefox even Javascript is enabled.
.innerText is not supported in Mozila, use .innerHTML instead.
 
Share this answer
 
Comments
Gopal Krishna Ranjan 21-Nov-11 6:17am    
I have removed the innertext part but the below part where i am checking for cells.length and

document.getElementById(checkBoxList.id + '_' + [0]).checked == true

these also are not working
Please help me.......
Thnx
demouser743 21-Nov-11 6:31am    
Have you tried as per the given links.. Are you using check boxes in grid view or any other way
Download Firebug[^] for Firefox

Now debug your functions by adding a breakpoint in Firebug, you'll see where the errors occur and with a bit of searching you should be able to find how to fix

It's much better to learn how *you* can fix these issues by using the correct debugging tools
 
Share this answer
 
Thanx everyone who tried to opt my query.

It's worling in both IE as well as FireFox.

But i was frustrated...............too much...........But finally got it.........


//Method
//First i find the total items in the listbox from my codebehind before pageload
//TOTLEN - cblStatus.Items.Count.ToString() from code behind
//cblStatus.Attributes.Add("onclick", "UnCheckAll(" + //cblStatus.Items.Count.ToString() + ")")


function UnCheckAll(TOTLEN) {
checkBoxList = document.getElementById('cblStatus');
if (document.getElementById('cblStatus_0').checked == true) {
for (i = 1; i < TOTLEN; i++) {
var checkBox = document.getElementById('cblStatus_' + [i]);
checkBox.checked = false;
checkBox.disabled = true;
}
}
else {
for (i = 1; i < TOTLEN; i++) {
var checkBox = document.getElementById('cblStatus_' + [i]);
checkBox.disabled = false;
}
document.getElementById('cblStatus_0').checked = false;
document.getElementById('cblStatus_0').disabled = true;
}
//Enable sourced now
if (EnableSourced(TOTLEN, checkBoxList)) {
document.getElementById('cblStatus_0').disabled = false;
}
}
//To enable sourced checkbox
function EnableSourced(TOTLEN, checkBoxList) {
var RETVAL = false;
for (i = 1; i < TOTLEN; i++) {
//Get the checkboxlist item
var checkBox = document.getElementById('cblStatus_' + [i]);
if (checkBox.checked == true) {
return false;
}
else {
RETVAL = true;
}
}
return RETVAL;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900