# w3c validating javascript.



## Cori_Zen (Jul 27, 2006)

Hello 

I have this little javascript that i am trying to validate with w3c. I recieve two errors with these two lines:

document.write('</select>');
document.write('</form>');

Is there a way to get the script to validate or should i use another script instead? Below is the script i am working with in my html document.

<script language="JavaScript" type="text/javascript">
<!--
// original code by Bill Trefzger 12/12/96
function go(){
if (document.selecter.select1.options[document.selecter.select1.selectedIndex].value != "none") {
location = document.selecter.select1.options[document.selecter.select1.selectedIndex].value
}
}
//-->
</script>

<script language="JavaScript" type="text/javascript">
<!-- 
document.write('<form name="selecter"><select name="select1">');
document.write('<option value=none>Choose from a range of our products');
document.write('<option value=none>---------------------------');
document.write('<option value="Music_Albums.html">Music Albums');
document.write('<option value="Loops_Packs.html">Loop Packs');
document.write('<option value="3D_Models.html">3D Models');
document.write('<option value="Vsti_Synth.html">Vsti Synth');
document.write('<option value="Texture_Packs.html">Texture Packs');
document.write('<option value=none>---------------------------');
document.write('<option value="http://www.darkfrog.orcon.net.nz/Products.html">Products');
document.write('<option value="http://www.darkfrog.orcon.net.nz/TOS.html">Terms of service');
document.write('</select>');
document.write('<input type="button" value="Go" onclick="go()">');
document.write('</form>');
// end hiding contents -->
</script>


----------



## DJ-Zep (Mar 11, 2006)

Hello Cori_Zen. Welcome to TSF!

Maybe the validator is a little picky with the HTML involved. I added the optional closing tag for your options.

*Here is the new code:*
<script language="JavaScript" type="text/javascript">
<!--
document.write('<form name="selecter"><select name="select1">');
document.write('<option value="none">Choose from a range of our products</option>');
document.write('<option value="none">---------------------------</option>');
document.write('<option value="Music_Albums.html">Music Albums</option>');
document.write('<option value="Loops_Packs.html">Loop Packs</option>');
document.write('<option value="3D_Models.html">3D Models</option>');
document.write('<option value="Vsti_Synth.html">Vsti Synth</option>');
document.write('<option value="Texture_Packs.html">Texture Packs</option>');
document.write('<option value="none">---------------------------</option>');
document.write('<option value="http://www.darkfrog.orcon.net.nz/Products.html">Products</opstion>');
document.write('<option value="http://www.darkfrog.orcon.net.nz/TOS.html">Terms of service</option>');
document.write('</select>');
document.write('<input type="button" value="Go" onclick="go()">');
document.write('</form>');
// end hiding contents -->
</script>


----------



## Cori_Zen (Jul 27, 2006)

*silly script.*

Thanks for the help DJ_Zep,

Im still getting errors lol. 12 of these.



> Error Line 32 column 80: end tag for element "OPTION" which is not open.
> ... from a range of our products</option>');
> The Validator found an end tag for the above element, but that element is not currently open. This is often caused by a leftover end tag from an element that was removed during editing, or by an implicitly closed element (if you have an error related to an element being used where it is not allowed, this is almost certainly the case). In the latter case this error will disappear as soon as you fix the original problem.


I had a good read of this page here..

Navigational pulldown menus in HTML

Seems to have some usefull information on the use of drop down menus. I guess if i want to use this script ill have to live with it not validating. From what i read at the above url using javascript can make pages less accessible to those who turn off java in thier browsers and even by providing a handy little tip to say "requires java to be turned on" can prove annoying to the user.:4-dontkno 

Im going back to the drawing board on this one and will look for a better alternative.


----------



## Cori_Zen (Jul 27, 2006)

*external javascript files.*

I found a way to get the page to validate.

I just made the file an external .js and added this code to my page. :smile: 



> <div>
> <CENTER>
> <script src="menu.js" type="text/javascript">
> </script>
> ...


----------

