By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,655 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

set checkbox

P: n/a
i'm having trouble setting a checkbox to checked and unchecked

I want to have a form where you click a button. onclick would call a
function that
checks a checkbox on the form.
in the head:
function clearItem(thisOne){
var fset = document.getElementById(thisOne);
var inputs = fset.getElementsByTagName("input");
for (var i = 0; i<inputs.length; i++)
inputs.item(i).value="checked";
document.up_data.att3.checked()=(true);
}
in the body:
<form action="maint.pl" method="POST" name="up_data">
<input type="button" name="xxclrField_fnct1" value="clear"
onclick='clearItem("clrField_fnct1")'>
<input type="checkbox" name="att3">

<fieldset id="clrField_fnct1">
<input type="text" size=30 name="stu1" value="">
<input type="text" size=30 name="frm1" value="">

</fieldset>
</form>
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Almost there.

I think try:
document.up_data.att3.checked=true;

instead of what you haveat the moment :
document.up_data.att3.checked()=(true);

Stu

"Ben Dover - Mental Patient 0057"
<Be*******@psychiatric-center.Bellevue-Hospital.com> wrote in message
news:3F***************@psychiatric-center.Bellevue-Hospital.com...
i'm having trouble setting a checkbox to checked and unchecked

I want to have a form where you click a button. onclick would call a
function that
checks a checkbox on the form.
in the head:
function clearItem(thisOne){
var fset = document.getElementById(thisOne);
var inputs = fset.getElementsByTagName("input");
for (var i = 0; i<inputs.length; i++)
inputs.item(i).value="checked";
document.up_data.att3.checked()=(true);
}
in the body:
<form action="maint.pl" method="POST" name="up_data">
<input type="button" name="xxclrField_fnct1" value="clear"
onclick='clearItem("clrField_fnct1")'>
<input type="checkbox" name="att3">

<fieldset id="clrField_fnct1">
<input type="text" size=30 name="stu1" value="">
<input type="text" size=30 name="frm1" value="">

</fieldset>
</form>

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.