Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript : uncheck checked box

Status
Not open for further replies.

lucyc

Programmer
Mar 1, 2002
62
US
Hi,

I would like to find a way to do the following:

I have a page with 10 checkboxes(5 of them with prefix ckNeeds and 5 with prefix ckPlan) and 8 textbox(4 with prefix txtNeeds and 4 with prefix txtPlan). If the N/A(with prefix ckNeeds) checkbox is checked, I want the other 4 checkboxes with prefix ckNeeds to be unchecked if they are checked , also if there are value in the 4 textbox with prefix txtNeeds then I would like to earse the value on the those text box. I will really appreciate if anyone can give me any idea on how to do this. Thanks
 
<script>
function Checker(){
if (document.myForm.ckNeeds5.checked == true){
document.myForm.ckNeeds1.checked = false
document.myForm.ckNeeds2.checked = false
document.myForm.ckNeeds3.checked = false
document.myForm.ckNeeds4.checked = false

document.myForm.ckNeedstext1.value = &quot;&quot;
document.myForm.ckNeedstext2.value = &quot;&quot;
document.myForm.ckNeedstext3.value = &quot;&quot;
document.myForm.ckNeedstext4.value = &quot;&quot;
}
}
function unChecker(inField){
if (inField.type==&quot;checkbox&quot;){
if (inField.checked == true){
document.myForm.ckNeeds5.checked == false
}
}
else {
if (inField.value != &quot;&quot;){
document.myForm.ckNeeds5.checked == false
}
}
}
</script>
<form name=myForm>
<input type=checkbox name=&quot;ckNeeds1&quot; onClick=&quot;unChecker(this)&quot;>
<input type=checkbox name=&quot;ckNeeds2&quot; onClick=&quot;unChecker(this)&quot;>
<input type=checkbox name=&quot;ckNeeds3&quot; onClick=&quot;unChecker(this)&quot;>
<input type=checkbox name=&quot;ckNeeds4&quot; onClick=&quot;unChecker(this)&quot;>
<input type=checkbox name=&quot;ckNeeds5&quot; onClick=&quot;Checker()&quot;>

<input name=ckNeedstext1 onBlur=&quot;unChecker(this)&quot;>
<input name=ckNeedstext2 onBlur=&quot;unChecker(this)&quot;>
<input name=ckNeedstext3 onBlur=&quot;unChecker(this)&quot;>
<input name=ckNeedstext4 onBlur=&quot;unChecker(this)&quot;>
</form> -----------------------------------------------------------------
[pc] Be nice. It's only doing what you tell it to do.
mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top