[Javascript] 'name' property in forms not XHTML valid

Robert Kim Wireless Internet Advisor evdo.hsdpa at gmail.com
Tue Jan 24 11:45:36 CST 2006


Have you tried asking the MIT Forum?

On 1/24/06, Jonathan Gold <johnnyclock at gmail.com> wrote:
> Hi!
>
> I have some older web pages that use forms and on each one of them I
> refer to a function that clears the entries, thus:
>
>            function clearColors()
>      {
>            for (var i = 0; i < 3; i++)
>            {
>                  document.formColors.elements[i].value="";
>            }
>      }
>
> And in the markup I use the following:
>
>            <form id="formColors" name="formColors" action="">
>
>
> And when I click on a button that says to clear the entries, the three
> text input boxes are cleared. Here's the whole page:
> http://home.pacbell.net/jonnygee/auxiliary/colorpage.htm
>
>
> PROBLEM: nowadays, I am trying to write valid XHTML. I seem to need
> the form's NAME attribute for the purpose of the javascript, but the
> HTML validator tells me:
>
> <quote>
> This page is not Valid XHTML 1.0 Strict!
> Below are the results of checking this document for XML
> well-formedness and validity.
>
>   1. Error Line 104 column 27: there is no attribute "name".
>
>      <form id="formColors" name="formColors" action="">
>
>      You have used the attribute named above in your document, but
> the document type you are using does not support that attribute for
> this element… </quote>
>
>
>
> The upshot is that the 'name' attribute has been replaced with the
> 'id' attribute. In fact, that's why I added an id attribute in my form
> tag. But without the name attribute my javascript doesn't function.
>
> So here's the QUESTION:
>
> How can I refer to the form, using its 'id' attribute, in my
> clearColors code at the top of this message.
>
>
> Thanks for any help you can give,
>
> Jonathan
>
> _______________________________________________
> Javascript mailing list
>
>
>


--
Robert Q Kim, Wireless Internet Advisor
http://evdo-coverage.com/repeater.html
http://hsdpa-coverage.com

2611 S. Pacific Coast Highway 101
Suite 102
Cardiff by the Sea, CA 92007
206 984 0880


More information about the Javascript mailing list