Hello everyone,
I am having another small issue. I have a code that makes my viewers' lives a bit easier by automatically checking a radio button or checkbox when
another radio button or checkbox is clicked. I will explain further.
There are two parts to this issue.
Part I) The form and code:
The form looks like this:
() Radio1 label
[] Checkbox1 label
[] Checkbox2 label
[] Checkbox3 label, [Textbox]
() Radio2 label
() Radio3 label
-----------------------------------------------------------
() is a radio button
[] is a checkbox
Now when Checkbox1, Checkbox2, or Checkbox3 are checked (onclick), Radio1 is automatically checked (Checkboxes are a 'directory' under Radio1). When Radio2 or Radio3 are checked (onclick), the Checkboxes are all
unchecked. Also, when someone types into the textbox (after Checkbox3), Checkbox3 as well as Radio1 are checked. And when Checkbox3 is unchecked OR Radio2 or Radio3 are checked, the textbox is cleared. (Pheww...)
Here is the code I have so far:
Code:
function selectFields(){
var count=0;
for(var i=0;i<document.forms[1].Checkboxes.length;i++){
if(document.forms[1].Checkboxes[i].checked){
count++;
}
}
document.forms[1].type[0].checked=(count>0);document.forms[1].type[0 - 1].checked=(count<=0);
}
The checkboxes have an onclick value of: onclick="selectFields()".
The radio buttons have an onclick value of: onclick="for(i=0;i<this.form.Checkboxes.length;i++ )this.form.problem[i].checked=0;".
The textbox (after Checkbox3) has an onfocus value of: onfocus="this.form.problem[2].checked=true;selectFields();".
The script works, but Internet Explorer says "Error on page" in the status bar, telling me that something is wrong...
Part II) Form field names
Now, in my code, I use "Checkboxes" as the names for all three checkboxes. However, I need a
different name for each one since my
php code (which submits the form content to me by email) would overwrite the checkbox values if more than one is checked. Now, different names would require difficult coding, which I don't really know how to do

.
Any help on this would be greatly appreciated.
Cheers and thanks,
SWagner