Javascript 单选按钮启用多个复选框
我有下面的代码 第1阶段单选按钮必须启用其下方的2个复选框,第2阶段单选按钮也是如此 如果选择了“其他”单选按钮,则必须再次禁用复选框 我已经有50%的想法在起作用,但也不知道如何在第二阶段做到这一点 下面是我的代码。我的JavaScript知识非常贫乏。提前谢谢你Javascript 单选按钮启用多个复选框,javascript,html,button,checkbox,radio,Javascript,Html,Button,Checkbox,Radio,我有下面的代码 第1阶段单选按钮必须启用其下方的2个复选框,第2阶段单选按钮也是如此 如果选择了“其他”单选按钮,则必须再次禁用复选框 我已经有50%的想法在起作用,但也不知道如何在第二阶段做到这一点 下面是我的代码。我的JavaScript知识非常贫乏。提前谢谢你 <html> <head> </head> </body> <table border=1> <tr> <td> <f
<html>
<head>
</head>
</body>
<table border=1>
<tr>
<td>
<form name="phaseform" action=""><font size=2>
<input type="radio" name="phase" value="1" id="phase" onclick="checkbox(0)" />
<label for="phase1">Phase 1</label>
</td>
<td><font size=2>
<input type="radio" name="phase" value="2" id="phase" onclick="checkbox(1)" />
<label for="phase2">Phase 2 (after 17 days)</label>
</td>
</tr>
<tr>
<td><font size=2>
<input type="checkbox" disabled checked id="TerminateP1" name="TerminateP1" value="IN">Terminate AD account<br>
<input type="checkbox" disabled checked id="MailboxAccessP1" name="MailboxAccessP1" value="IN">Grant mailbox access to manager<br>
</td>
<td><font size=2>
<input type="checkbox" disabled checked id="TerminateP2" name="TerminateP2" value="IN">Fully terminate AD account<br>
<input type="checkbox" disabled checked id="DisableMailboxP2" name="DisableMailboxP2" value="IN">Disable mailbox<br>
</td>
</tr>
</form>
<script type="text/javascript">
function checkbox(val)
{
if(val)
document.phaseform.TerminateP1.setAttribute("disabled",val)
else
document.phaseform.TerminateP1.removeAttribute("disabled",val)
if(val)
document.phaseform.MailboxAccessP1.setAttribute("disabled",val)
else
document.phaseform.MailboxAccessP1.removeAttribute("disabled",val)
}
</script>
</table>
</body>
<html>
第一阶段
第二阶段(17天后)
终止广告帐户
向管理器授予邮箱访问权限
完全终止广告帐户
禁用邮箱
功能复选框(val)
{
if(val)
document.phaseform.TerminateP1.setAttribute(“已禁用”,val)
其他的
document.phaseform.TerminateP1.removeAttribute(“已禁用”,val)
if(val)
document.phaseform.MailboxAccessP1.setAttribute(“已禁用”,val)
其他的
document.phaseform.MailboxAccessP1.removeAttribute(“已禁用”,val)
}
删除了泰勒的带条纹的表单代码,现在它在HTA中正常工作。有人能告诉我,如果下面的代码可能会导致任何未来的问题吗
function checkbox(val)
{
TerminateP1.setAttribute("disabled",1)
MailboxAccessP1.setAttribute("disabled",1)
TerminateP2.setAttribute("disabled",1)
DisableMailboxP2.setAttribute("disabled",1)
if(val)
{
TerminateP2.removeAttribute("disabled")
DisableMailboxP2.removeAttribute("disabled")
}
else
{
TerminateP1.removeAttribute("disabled")
MailboxAccessP1.removeAttribute("disabled")
}
}
谢谢你,泰勒,在浏览器中工作很好。但是,作为HTA应用程序,一旦激活,它就无法禁用阶段2复选框。知道为什么吗?在前4个功能行中添加了“1”而不是“val”,现在在HTA中似乎运行良好。你能检查一下这是否会对任何事情产生不良影响吗?e、 g.TerminateP1.setAttribute(“禁用”,1)
function checkbox(val)
{
TerminateP1.setAttribute("disabled",1)
MailboxAccessP1.setAttribute("disabled",1)
TerminateP2.setAttribute("disabled",1)
DisableMailboxP2.setAttribute("disabled",1)
if(val)
{
TerminateP2.removeAttribute("disabled")
DisableMailboxP2.removeAttribute("disabled")
}
else
{
TerminateP1.removeAttribute("disabled")
MailboxAccessP1.removeAttribute("disabled")
}
}