Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
LinkBack Thread Tools
Old 10-28-2006, 09:27 PM   #1 (permalink)
Registered User
 
Cori_Zen's Avatar
 
Join Date: Jul 2006
Location: New Zealand
Posts: 20
OS: xp home


Send a message via MSN to Cori_Zen
w3c validating javascript.

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>
Cori_Zen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 10-29-2006, 09:47 AM   #2 (permalink)
Design Team
 
DJ-Zep's Avatar
 
Join Date: Mar 2006
Location: Philadelphia
Posts: 1,541
OS: Windows Vista Home Premium (x64)

My System

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>
__________________
Nice music blog

Nvu || Notepad++ || Apache || PHP || Keep TSF Alive

"The great thing about a computer notebook is that no matter how much you stuff into it, it doesn't get bigger or heavier."
DJ-Zep is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-29-2006, 08:07 PM   #3 (permalink)
Registered User
 
Cori_Zen's Avatar
 
Join Date: Jul 2006
Location: New Zealand
Posts: 20
OS: xp home


Send a message via MSN to Cori_Zen
silly script.

Thanks for the help DJ_Zep,

Im still getting errors lol. 12 of these.

Quote:
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.

Im going back to the drawing board on this one and will look for a better alternative.
Cori_Zen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-29-2006, 10:40 PM   #4 (permalink)
Registered User
 
Cori_Zen's Avatar
 
Join Date: Jul 2006
Location: New Zealand
Posts: 20
OS: xp home


Send a message via MSN to Cori_Zen
Idea 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.

Quote:
<div>
<CENTER>
<script src="menu.js" type="text/javascript">
</script>
</CENTER>
</div>
Cori_Zen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 12:35 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85