RE: [PHP] DOCTYPE, javascript and Firefox
| From: | Boyd, Todd M. | Date: | Thu, 30 Oct 2008 15:17:54 +0000 |
| Subject: | RE: [PHP] DOCTYPE, javascript and Firefox | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-282632@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Arno Kuhl [mailto:akuhl@telkomsa.net]
> Sent: Thursday, October 30, 2008 9:24 AM
> To: 'PHP - General'
> Subject: RE: [PHP] DOCTYPE, javascript and Firefox
>
>
>
> -----Original Message-----
> From: tedd [mailto:tedd.sperling@gmail.com]
> Sent: 30 October 2008 03:58 PM
> To: arno@dotcontent.net; 'PHP - General'
> Cc: Arno Kuhl
> Subject: Re: [PHP] DOCTYPE, javascript and Firefox
>
> At 3:45 PM +0200 10/30/08, Arno Kuhl wrote:
> >I came across an odd thing with DOCTYPE, javascript and Firefox 3
that
> >has me stumped. Not exactly a php issue but hoping someone else on
the
> >list has seen this before. (At least the script is php, hope that
> >counts)
> >
> >I have the following code in my header script:
> >
> >echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\"
>
> >>\"http://www.w3.org/TR/html4/loose.dtd\">\n";
> >
> >
> >Elsewhere I have (simplified):
> >
> >echo "<input type='radio' name='autostart'
> >value='0'"
> > ."onclick=\"autostartlabel.className='disable';"
> > ."article.startdate.disabled=true;\" />No"
> > ."<input type='radio' name='autostart'
> > value='1'"
> > ."onclick=\"autostartlabel.className='normal';"
> > ."article.startdate.disabled=false;\" />"Yes"; ...
> >echo "<label id='autostartlabel'>Startdate"
> > ."<input type='text' name='startdate'
> > id='startdate'
> disabled=true />"
> > ."</label>";
> >
> >
> >It's simply 2 radio buttons and if "yes" is clicked related form
> fields
> >are enabled, if "no" is clicked they're disabled.
> >
> >This code works fine in IE, Opera and Chrome, but gives a javascript
> >error in FF when I click the radio button: "autostartlabel is not
> defined".
> >However if I comment out the DOCTYPE line in the header it works fine
> >in all browsers including FF. (Took ages to narrow it down to the
> >DOCTYPE.) Does anyone know why, and how to fix it?
> >
> >Cheers
> >Arno
>
> Arno:
>
> Wild guess, place this --
>
> <?php header('Content-Type: text/css; charset=UTF-8'); ?>
>
> -- before the DOCTYPE
>
> HTH's,
>
> tedd
>
> --
> -------
>
> Hi tedd
>
> Thanks for the suggestion. What it did though was output the html as
> text
> rather than render the html. At least it's consistent across all
> browsers...
> I tried changing it to "Content-Type: text/html;" which rendered the
> html
> but still gave a js error in FF.
Have you tried referencing the "autostartlabel" radio list using
"document.autostartlabel" instead? If that doesn't work, I seem to
remember that the "name" attribute is being phased out of XHTML
altogether. Perhaps Firefox is just a bit more adept at truly following
the DOCTYPE specification?
HTH,
Todd Boyd
Web Programmer