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

When i pass the check box values in the javascript, the values coming. But,
It will thorow the error.

I am using ASP type Check box and i pass the values into javascript.

See my code
-----------
C#
function Val()
{
var Ctrl;
row = document.forms[0].row.value
col = document.forms[0].col.value
for(i=1;i<=row;i++)
{
	for(j=1;j<=col;j++)
	{
		Ctrl = "Row"+i+"Col"+j
		if(document.getElementById(Ctrl).checked ==true)''Microsoft JScript runtime error: Object required
		{
			document.getElementById(Ctrl).value ="Y"
		}
		else
		{
			document.getElementById(Ctrl).value ="N"
		}
	}
}

HTML
<input type="checkbox" name="<%="Row"&row & "Col"&col%>"



Error is below :
------------------
"Microsoft JScript runtime error: Object required"


Previously it was working fine. But, now it's not working.

What is the problem..?
Posted
Updated 27-Sep-11 20:56pm
v2
Comments
Yuri Vital 28-Sep-11 3:33am    
try getElementByName() instead of "getElementById" because your checkbox have not id attribute, but name attribute
gani7787 28-Sep-11 4:53am    
ok..thanks...

C#
<%--   <script language="javascript" type="text/javascript" >
   function checkCheckBoxes()
   {
if (document.newmember.CheckBox1.checked == false)
{
alert ('Please Agree Terms & Condition First!');
return false;
}
else
{
return true;
}
}

   </script>
 
Share this answer
 
Why dont you try this

document.forms[0].elements[i].checked==true
 
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