[Javascript] Radio Button Value Property Does Not Exist in Netscape 6.1?

Rodney Myers rodney at aflyingstart.net
Fri Oct 26 14:34:08 CDT 2001


Gregory,

 I find the observations in your  posting disturbing.
The more so because as the 0 element is clearly marked as checked one might
expect at least that its value would be returned if a construct such as
document.MyForm.txtStep1.value is to give any value (or had you manually
checked the [1] button?)

Probably the browser anomaly will require special coding, but it will not be
much good unless you can be sure that document.MyForm.txtStep1.value returns
the value of a checked button - and of course it is quite possible to
present  a set of radio buttons with nothing checked.

typeof() may help things along a fraction since it may be used (one hopes!!)
to find "undefined" as in

if ( typeof(document.MyForm.txtStep1.value) =="undefined") ....

hth

Rodney

 BTW I use this function to get values from rb sets

function getRadioVal(rb){
var L=rb.length;var ret="";
for (var i = 0 ; i< L ; i++)
 { if(rb[i].checked) { ret=rb[i].value; break; } }
return(ret);
}

This returns an empty string if nothing is checked



gregory.john.toland at census.gov wrote:

> I have the following code:
>
> <form enctype="text/plain" id="myForm" method="get"
>       name="myForm" onSubmit="return true;">
>    <input checked id="txtStep1" name="txtStep1"
>           tabindex="1"
>           title="Tabular Profile" type="radio"
>           value="Tabular">Tabular</input>
>    <input id="txtStep1" name="txtStep1"
>           title="Narrative Profile" type="radio"
>           value="Narrative">Narrative</input>
> </form>
>
> In Netscape 4.X and IE 5.X the code:
>
>    alert( document.MyForm.txtStep1[01].value );
>
> returns "Narrative"
>
> In Netscape 6.1 the same code gives an error message in the Javascript
> console:
>
>    "Error: document.myForm.txtStep1[1] has no properties."
>
> Did something change?
>
> In Netscape 6.1 if I use:
>
>    alert( document.MyForm.txtStep1.value );
>
> I get the correct answer, "Narrative".  I cannot use this code in IE 5.X
> and NN 4.X, however.  It gives a result of "undefined".  Must we have
> different code for the two sets of browsers for accessing such basic
> properties of form elements?  Is there any documentation out there that
> talks about this?  According to
> http://developer.netscape.com/docs/manuals/js/client/jsref/radio.htm the
> last example shows my code should work under JS 1.3/NN 6.1.  Any ideas?
>
> Gregory J Toland
> Sr. Systems Architect
> CHM, Inc.
> (301) 457-8058
> tolan002 at census.gov
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript

--
Shop at ssistant Add-ons and Developer Workshops
http://www.aflyingstart.net/addons/

Rodney Myers
Based in Oxford, England
Technical Director, Shop at ssistant eCommerce Solutions





More information about the Javascript mailing list