/    Sign up×
Community /Pin to ProfileBookmark

feel like I’m in the twilght zone

OK, I have a routine that if you “check” a checkbox, the values from the first section are duplicated in the second, uncheck it and they go away awaiting input…everything works OK except for the oddity that if I click a radio button in section1 for Male, check the checkbox, the values change accordinglt BUT the radio button in section2 is selected as Female…if section1 radio is Female, it comes across Female…I even tried a new selection in section2 coded as variable[2] and it was selected correctly…code is as follows:

<SCRIPT LANGUAGE=”JavaScript”>

var CndnOwnFirstName = “$CndnOwnFirstName$”;
var CndnOwnLastName = “$CndnOwnLastName$”;
var CndnOwnStreet = “$CndnOwnStreet$”;
var CndnOwnCity = “$CndnOwnCity$”;
var CndnOwnStProv = “$CndnOwnStProv$”;
var CndnOwnZipPC = “$CndnOwnZipPC$”;
var CndnOwnCountry = “$CndnOwnCountry$”;
var CndnOwnHomePhone = “$CndnOwnHomePhone$”;
var CndnOwnBusPhone = “$CndnOwnBusPhone$”;
var CndnOwnSS = “$CndnOwnSS$”;
var CndnOwnDOB = “$CndnOwnDOB$”;
var CndnOwnEmail = “$CndnOwnEmail$”;
var CndnOwnGender = “$CndnOwnGender$”;

function OwnEqualInsured() {

if (document.forms[0].copy.checked) {
document.forms[0].CndnOwnFirstName.value=document.forms[0].CndnInsFirstName.value;
document.forms[0].CndnOwnLastName.value=document.forms[0].CndnInsLastName.value;
document.forms[0].CndnOwnStreet.value=document.forms[0].CndnInsStreet.value;
document.forms[0].CndnOwnCity.value=document.forms[0].CndnInsCity.value;
document.forms[0].CndnOwnStProv.value=document.forms[0].CndnInsStProv.value;
document.forms[0].CndnOwnZipPC.value=document.forms[0].CndnInsZipPC.value;
document.forms[0].CndnOwnCountry.value=document.forms[0].CndnInsCountry.value;
document.forms[0].CndnOwnHomePhone.value=document.forms[0].CndnInsHomePhone.value;
document.forms[0].CndnOwnBusPhone.value=document.forms[0].CndnInsBusPhone.value;
document.forms[0].CndnOwnSS.value=document.forms[0].CndnInsSS.value;
document.forms[0].CndnOwnDOB.value=document.forms[0].CndnInsDOB.value;
document.forms[0].CndnOwnEmail.value=document.forms[0].CndnInsEmail.value;

if (document.forms[0].CndnInsGender[0].value=”Male”)
document.forms[0].CndnOwnGender[0].checked=true;
if (document.forms[0].CndnInsGender[1].value=”Female”)
document.forms[0].CndnOwnGender[1].checked=true;

}
else {
document.forms[0].CndnOwnFirstName.value=CndnOwnFirstName;
document.forms[0].CndnOwnLastName.value=CndnOwnLastName;
document.forms[0].CndnOwnStreet.value=CndnOwnStreet;
document.forms[0].CndnOwnCity.value=CndnOwnCity;
document.forms[0].CndnOwnStProv.value=CndnOwnStProv;
document.forms[0].CndnOwnZipPC.value=CndnOwnZipPC;
document.forms[0].CndnOwnCountry.value=CndnOwnCountry;
document.forms[0].CndnOwnHomePhone.value=CndnOwnHomePhone;
document.forms[0].CndnOwnBusPhone.value=CndnOwnBusPhone;
document.forms[0].CndnOwnSS.value=CndnOwnSS;
document.forms[0].CndnOwnDOB.value=CndnOwnDOB;
document.forms[0].CndnOwnEmail.value=CndnOwnEmail;
if (document.forms[0].CndnInsGender[0].value=”Male”)
document.forms[0].CndnOwnGender[0].checked=false;
if (document.forms[0].CndnInsGender[1].value=”Female”)
document.forms[0].CndnOwnGender[1].checked=false;

}
}
</script>

At first I thought mabe I put in the letter “O” for the number zero “0” but that wasn’t it…section2 has 4 radio choices Male, Female, Corporate, Other which I reference as [0],[1],[2],[3] respectively…so above when I said I tried a new variable it was [2] and it correctly returned Corporate…pretty stumped at this point…what idiotic error did I make this time?

Thanks,
Ron

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@rjusaauthorNov 10.2003 — don't know if this helps any but in case1, radio check Male section1, click checkbox, values get fed correctly except for male in section2...comes out female...when I run case2 with radio check Female section1, everything seems OK...BUT, when I uncheck and review section1, the radio value is now set at Male!

Ron
Copy linkTweet thisAlerts:
@rjusaauthorNov 10.2003 — well, I figured it out...proper code is:

if (document.forms[0].CndnInsGender[0].checked)

document.forms[0].CndnOwnGender[0].checked=true;

if (document.forms[0].CndnInsGender[1].checked)

document.forms[0].CndnOwnGender[1].checked=true;

}

else {

if (document.forms[0].CndnInsGender[0].checked)

document.forms[0].CndnOwnGender[0].checked=false;

if (document.forms[0].CndnInsGender[1].checked)

document.forms[0].CndnOwnGender[1].checked=false;

Ron
×

Success!

Help @rjusa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...