我有下面给出的代码:
当我单击被拒绝的复选框时,它的工作正常,它显示了textarea,但是当我取消选中被拒绝的复选框时,它并没有隐藏它。
请帮忙....
<script type="text/javascript">
function checkValue() {
var rejected=document.forms["frmcnt"]["ar"].checked
if (rejected = 'Rejected') {
document.getElementById('xtraInfo').style.display='';
} else {
document.getElementById('xtraInfo').style.display='none';
}
}
</script>
Accepted: <input type='checkbox' name='ar' value='Accepted' />
Rejected: <input type='checkbox' name='ar' value='Rejected' onClick="return checkValue(this)" />
<div id="xtraInfo" style="text-align:center; display:none; font-weight:bold;">
<center>Rejection Detail:</center><br>
<textarea width="900" style="width: 910px; resize:vertical;" name="rejectdt"><?php if( $_SERVER['REQUEST_METHOD'] === 'POST' ) { print_r($_POST['rejectdt']); } ?></textarea>
</div>
最佳答案
HTML:
Rejected: <input type='checkbox' name='reject' id='reject' value='Rejected' onClick="checkValue()" />
功能:
function checkValue()
{
if(document.getElementById("reject").checked == true)
{
document.getElementById('xtraInfo').style.display='block';
}
else
{
document.getElementById('xtraInfo').style.display='none';
}
}
关于javascript - 取消选中复选框时不隐藏文本区域,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18978372/