banging my head against a wall with this one

A

Andy Fish

Hi,

when I try to load this page on netscape or mozilla (latest versions), I get
the error

Error: document.form1.radiogroup[0] has no properties.

It works fine on Opera or IE.

I'm sure it is something to do with the definition of the <input> tags
because if I move the type=radio to the beginning it works all right. I'm
not sure whether it's a bug in the browser or a misunderstanding on my part
which the other browsers are working around.

If this is a bug in mozilla, does anybody know any other workaround except
changing the order of the attributes. Unfortunately, I'm generating this
HTML with XSL and don't have control over the order the attributes get
generated.

<html>
<BODY onload="alert( document.form1.radiogroup[0].value);">
<FORM name="form1" id="form1" >
<input id="radiogroup" value="one" name="radiogroup" type="radio"> one
<input id="radiogroup" value="two" name="radiogroup" type="radio" > two
</FORM>
</BODY>
</html>
 
L

Lasse Reichstein Nielsen

Andy Fish said:
I must admit I have been a bit perplexed by this whole name and id thing for
controls - why you need both and what they're for.

The short version is:

For HTML, form elements only need name attributes. If you add id
attributes, make them different from the name attributes and globally
unique. Only the name attribute is used when you submit the form.

For XHTML, only certain elements accepts the name attribute, but that
includes form elements.

/L 'please don't top post'
 

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

Forum statistics

Threads
474,079
Messages
2,570,574
Members
47,207
Latest member
HelenaCani

Latest Threads

Top