/    Sign up×
Community /Pin to ProfileBookmark

Radio Buttons causing problems in FF and NS

I have an HTML form that works in all browsers… [B]only if I comment out the radio buttons part[/B]!!! The error is in this part but I can’t find it.

All I want to do with my radio buttons is this:

if (any radio button is selected) {
do this;
} else {
do that;
}

At this point, the radiobuttons part of my script works well in IE 6.0, whereas it is ignored in Firefox and Netscape.

Here is the script (just one part of it — the rest works perfectly in any browser, as I mentioned before):

[CODE]
document.getElementById(“range”).style.color = “#FF0000”;
myForm+=1;
for (var i=0; i<document.applForm.elements[“investment”].length; i++){
radio = document.applForm.elements[“investment”][i];
if (radio.checked == true) {
document.getElementById(“range”).style.color = “#000000”;
myForm-=1;
}
}

[/CODE]

[code=html]
<td><input type=”radio” value=”Yes” name=”investment” ></td>
<td><input type=”radio” value=”No” name=”investment” </td>

[/code]

I would appreciate any help.

to post a comment
JavaScript

11 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleApr 18.2007 — <input type="radio" value="No" name="investment"

should be

<input type="radio" value="No" name="investment" />
Copy linkTweet thisAlerts:
@theRatWonderApr 18.2007 — I've no idea what this "myForm" variable is... Seems an odd name for an integer tho....

Other than that, "document.applForm" I would have thought would be your problem. There is no "applForm" property of the "document" object.

document does have a "forms" property, which returns a node list of all the forms, so "document.forms.applForms" will give you your form object.
Copy linkTweet thisAlerts:
@andkhlauthorApr 18.2007 — I've no idea what this "myForm" variable is... Seems an odd name for an integer tho....

Other than that, "document.applForm" I would have thought would be your problem. There is no "applForm" property of the "document" object.

document does have a "forms" property, which returns a node list of all the forms, so "document.forms.applForms" will give you your form object.[/QUOTE]


[B]myForm[/B] -- is just a variable within my javascript. It can equal to zero (0), or one (1). If it equal to zero, then the form is submitted; if it equals to one -- the form is [U]not[/U] submitted (user is to fill out all the required fields). Like this:

if (myForm <= 0){

document.appForm.submit();

} else {

return false;

}

If any radiobutton IS selected, then myForm=0. If NOT selected, then myForm=1; There's nothing else to it.

[B]applForm[/B] -- is my HTML form id. That's all. Like this:

<form id= "applForm" >...</form>

The error is still in the radiobuttons part. I can't find it.

Here's how it is supposed to work in ALL browsers (click the submit button): example. The radio buttons work in IE only (as of now).
Copy linkTweet thisAlerts:
@andkhlauthorApr 18.2007 — <input type="radio" value="No" name="investment"

should be

<input type="radio" value="No" name="investment" />[/QUOTE]


I've done that --- didn't help, unfortunately.?
Copy linkTweet thisAlerts:
@theRatWonderApr 18.2007 — when I try this in Firefox, I get the error "document.applForm has no properties" which means you should be using "document.forms.applForms" instead.
Copy linkTweet thisAlerts:
@andkhlauthorApr 18.2007 — Thank you very much -- that did the trick!

One last quesion: where in Firefox one can look up errors, if any? In IE, one can click on the error icon in the lower left-hand corner... What about FF and Netscape?

Thanks again.
Copy linkTweet thisAlerts:
@JMRKERApr 18.2007 — Type 'javascript:' in the URL box (without "'" marks)
Copy linkTweet thisAlerts:
@theRatWonderApr 18.2007 — Wow I didn't know that.

I use the web developer toolbar - priceless.

https://addons.mozilla.org/en-US/firefox/addon/60
Copy linkTweet thisAlerts:
@theRatWonderApr 18.2007 — Sorry to be an insifferable know-it-all, but the solution was what I suggested in the first place.
Copy linkTweet thisAlerts:
@jasonahouleApr 18.2007 — Firebug is a really good add-on for debugging javascript.
Copy linkTweet thisAlerts:
@andkhlauthorApr 19.2007 — thanks, guys, for lots of important info!!!

Are there any such tool (javascript validator) for Netscape specifically?
×

Success!

Help @andkhl 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...