• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CheckBox Status

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ravi Kumar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Has per javaranch policy i have changed the name convention.
can you please help me out for my above problem.

thanks
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The function in the onclick is different than the function name you are showing us.

Eric
 
Ravi Kumar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

iam really Sorry about that mistake it should be clickRows instead of Rows_click.

Thanks
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic