| Author |
CheckBox Status
|
Ravi Kumar
Greenhorn
Joined: Apr 08, 2007
Posts: 9
|
|
Hi Everybody, I have 2 diffrent check boxes i need to get the status of those checkboxes. Here the below code Javascript function ClickRows(obj) { var i=0; var chxbox1=document.getElementsByName("CheckBox1"); var chxbox2=document.getElementsByName("CheckBox2"); if (obj.checked==true) { chxbox1[i].checked=true; chxbox2[i].checked=true; } else { chxbox1[i].checked=true; chxbox2[i].checked=true; } JSP "& lt;"INPUT type="CHECKBOX" name="CheckBox1"& lt;"%=i%"& lt;"" value="Y" "Rows_Click(this)" "& lt;" "& lt;"INPUT type="CHECKBOX" name="CheckBox2"& lt;"%=i%"& lt;"" value="Y" "Rows_Click(this)" It's giving as "undefined is null not an object" Please help me out. Thanks in advance.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
kumar, We're pleased to have you here with us in the JSP forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it. In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. You can change it here Welcome to JavaRanch!
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Ravi Kumar
Greenhorn
Joined: Apr 08, 2007
Posts: 9
|
|
Hi Has per javaranch policy i have changed the name convention. can you please help me out for my above problem. thanks
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
The function in the onclick is different than the function name you are showing us. Eric
|
 |
Ravi Kumar
Greenhorn
Joined: Apr 08, 2007
Posts: 9
|
|
Hi, iam really Sorry about that mistake it should be clickRows instead of Rows_click. Thanks
|
 |
Parthasarathy balakrishnan
Greenhorn
Joined: Apr 20, 2007
Posts: 14
|
|
Originally posted by kumar: Hi Everybody, I have 2 diffrent check boxes i need to get the status of those checkboxes. Here the below code Javascript function ClickRows(obj) { var i=0; var chxbox1=document.getElementsByName("CheckBox1"); var chxbox2=document.getElementsByName("CheckBox2"); if (obj.checked==true) { chxbox1[i].checked=true; chxbox2[i].checked=true; } else { chxbox1[i].checked=true; chxbox2[i].checked=true; } JSP "& lt;"INPUT type="CHECKBOX" name="CheckBox1"& lt;"%=i%"& lt;"" value="Y" "Rows_Click(this)" "& lt;" "& lt;"INPUT type="CHECKBOX" name="CheckBox2"& lt;"%=i%"& lt;"" value="Y" "Rows_Click(this)" It's giving as "undefined is null not an object" Please help me out. Thanks in advance.
----------------------------------- I have R&D over your code and reached the result: code: function ClickRows(obj) { alert(" the value of the check box is"+obj.checked);//this will return the status of the check box alert(" the value of the check box is"+obj.name);//this will give the name of the check box var i=0; //var chxbox1=document.getElementsByName("CheckBox1"); //var chxbox2=document.getElementsByName("CheckBox2"); var chxbox1=chxbox1[0].checked; var chxbox2=chxbox2[0].checked; alert(" The value of first checkBox"+chxbox1+"The value of the second ChecKBox"+chxbox2); alert("the value of the first checkbox "+chxbox1[0].checked+" And the checkbox2"+chxbox2[0].checked); if (obj.checked==true) { chxbox1[i].checked=true; chxbox2[i].checked=true; } else { chxbox1[i].checked=true; chxbox2[i].checked=true; } } I have not attached the HTML CODE because gave some error in javaranch by
|
Thanks and Regards,<br />-------------------<br />Parthasarathy Balakrishnan,<br />Bangalore.
|
 |
 |
|
|
subject: CheckBox Status
|
|
|