checkbox函数返回相同的开关结果 [英] checkbox function returning same result for on and off
问题描述
这是我的程序,它正在重新打印相同的消息已检查每次,无论是我的选择还是取消选中给定的复选框。
请看看。
< html>
< head>
< title>客户咨询< / title>
< SCRIPT language =" JavaScript1.2">
函数txtReasonState(name)
{
if(document.sysaccess.name.checked == false)
{
alert(" uncheked");
}
else
{
alert (已检查);
}
}
< / SCRIPT>
< / head>
< body>
< form name =" sysaccess" >
< input type ="复选框"名称= QUOT; checkbox1" onClick =" txtReasonState(this.name)">
< / form>
< / body>
< / html>
thax
Manoj
This is my program and it is resluting same message "checked" everytime, either i checed it or unchecked the given checkbox.
Please have a look .
<html>
<head>
<title>Customer Inquiry</title>
<SCRIPT language="JavaScript1.2">
function txtReasonState(name)
{
if (document.sysaccess.name.checked==false)
{
alert("uncheked");
}
else
{
alert("checked");
}
}
</SCRIPT>
</head>
<body>
<form name="sysaccess" >
<input type="checkbox" name="checkbox1" onClick="txtReasonState(this.name)">
</form>
</body>
</html>
thax
Manoj
推荐答案
hi,
这是我的程序,它正在重新打印相同的消息已检查每次,无论是我的选择还是取消选中给定的复选框。
请看看。
< html>
< head>
< title>客户咨询< / title>
< SCRIPT language =" JavaScript1.2">
函数txtReasonState(name)
{
if(document.sysaccess.name.checked == false)
{
alert(" uncheked");
}
else
{
alert (已检查);
}
}
< / SCRIPT>
< / head>
< body>
< form name =" sysaccess" >
< input type ="复选框"名称= QUOT; checkbox1" onClick =" txtReasonState(this.name)">
< / form>
< / body>
< / html>
thax
Manoj
This is my program and it is resluting same message "checked" everytime, either i checed it or unchecked the given checkbox.
Please have a look .
<html>
<head>
<title>Customer Inquiry</title>
<SCRIPT language="JavaScript1.2">
function txtReasonState(name)
{
if (document.sysaccess.name.checked==false)
{
alert("uncheked");
}
else
{
alert("checked");
}
}
</SCRIPT>
</head>
<body>
<form name="sysaccess" >
<input type="checkbox" name="checkbox1" onClick="txtReasonState(this.name)">
</form>
</body>
</html>
thax
Manoj
更改在两个地方。
Change at two places.
hi ...
是的......这将是一个解决方案。另一种方法是将条件的表达式更改为:
hi ...
yep ... that would be one solution. An other would be to change the expression for the condition to:
hi,
thanx dmjpro工作正常,但是gits也尝试了你的解决方案而且它无法正常工作。
再次感谢你们双方的回复
thanx dmjpro it is working fine, but gits also tried your solution and it is not working.
thanx again both of you for reply
这篇关于checkbox函数返回相同的开关结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!