I’m working with a form that has two separate address sections - one for home address, another for work address. There is a checkbox field at the top of each address section with a single entry - “Check if preferred | Yes”. The fields are called HomePref and WorkPref respectively.
The web client user is supposed to check either the Home or Work checkbox to indicate where they would like to receive their paper mail. I need to make sure that only one of the fields is checked - if they try to check both, the other should deselect.
In the onChange event of the HomePref field, I’ve put the following code:
var frm = window.document.forms[0];
var home = frm.HomePref;
var work = frm.WorkPref;
index=0
if (home[index].checked)
{
work[index].checked = false;
}
In the WorkPref field, I put the following:
var frm = window.document.forms[0];
var home = frm.HomePref;
var work = frm.WorkPref;
index=0
if (work[index].checked)
{
home[index].checked = false;
}
I can’t this code to work as I had expected. When I check the second box, I get the following error:
“checked is null or not an object”.
Any ideas? I’m stumped. This seems like it should be easy.
Karen