JavaScript problem in Netscape 7.1

R

Rick

I have an html program with the following section of java script code:

var selected = false ;
for ( var i = 0; i <= 1 ; ++i ) {
if (form.yesno.status == true )
{ selected = true }
}
if ( selected == false ) {
alert ("Please indicate whether you have purchased from us before");
return false;
}


This portion of the html program validates a radio button on a form. It
essentially is supposed to return false if the user fails to check one of
the two button choices. The relevant portion of the form is here:

Have you purchased from us before?<br>
Yes
<input type="radio" name="yesno"

value="yes">
No
<input type="radio" name="yesno" value="no">

This code has worked fine for years, and it still works fine with IE.
However when you open the page in Netscape 7.1, it always returns "false",
regardless of what the user checks. Is there some error in the code that IE
is forgiving but that Nescape is picking up? Or is this a Netscape bug?
 
K

kaeli

I have an html program with the following section of java script code:

var selected = false ;
for ( var i = 0; i <= 1 ; ++i ) {
if (form.yesno.status == true )


try
if (form.yesno.selected == true)
 
D

DU

Rick said:
I have an html program with the following section of java script code:

var selected = false ;
for ( var i = 0; i <= 1 ; ++i ) {
if (form.yesno.status == true )


status is not (and never was) a valid attribute or property for a radio
button
{ selected = true }
}


try
for ( var i = 0; i <= 1 ; i++ )
{
if(form.yesno.checked)
{ selected = true; }
}

I think you should post-fix the incrementation so that you test
form.yesno[0] first.
if ( selected == false ) {
alert ("Please indicate whether you have purchased from us before");
return false;
}


This portion of the html program validates a radio button on a form. It
essentially is supposed to return false if the user fails to check one of
the two button choices. The relevant portion of the form is here:

Have you purchased from us before?<br>
Yes
<input type="radio" name="yesno"

value="yes">
No
<input type="radio" name="yesno" value="no">

This code has worked fine for years, and it still works fine with IE.

I doubt that. status never was a valid property nor valid attribute of a
radio button, even in MSIE.
However when you open the page in Netscape 7.1, it always returns "false",
regardless of what the user checks. Is there some error in the code that IE
is forgiving but that Nescape is picking up? Or is this a Netscape bug?

DU
 
D

DU

kaeli said:
I have an html program with the following section of java script code:

var selected = false ;
for ( var i = 0; i <= 1 ; ++i ) {
if (form.yesno.status == true )



try
if (form.yesno.selected == true)


selected is for option; checked is for radio and checkbox buttons.

DU
 
T

Thomas 'PointedEars' Lahn

Rick said:
I have an html program [...]

JFTR: Since HTML is the HyperText Markup Language, not a programming
language like JavaScript, you have an HTML document, not an HTML program.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top