DOCTYPE, javascript and Firefox
| From: | Arno Kuhl | Date: | Thu, 30 Oct 2008 13:45:55 +0000 |
| Subject: | DOCTYPE, javascript and Firefox | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-282624@lists.php.net to get a copy of this message | ||
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