Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 02-12-2009, 12:14 PM Code Help
Super Talker

Posts: 116
Name: Paul
Location: South Africa
Trades: 0
I there to all, I need some help with a piect of script that works perfect, but it is causing my site to fail on xhtml validation at w3c, I have tried a couple things and cannot seem to get it to work so here it is.

I needed a way to use a check box that if clicked would show a form and if not would do nothing so here it is

Used to call the script
Code:
<script language="JavaScript" type="text/javascript" src="scripts.js"></script>
This was for the checkbox
Code:
<label for="cb_second_branch_toggle">
If you have a second branch you would like to add, please check this box: </label>
<label for="cb_second_branch_toggle"></label><inputname="cb_second_branch_toggle" type="checkbox" class="checkbox" id="cb_second_branch_toggle" tabindex="24"
value="Show_Second_Branch" onClick="toggle('toggle', this);" />
Scrips document
Code:
// JavaScript Document
function toggle( targetId, sourceId){
target = document.getElementById( targetId );
if (sourceId.checked){
target.style.display = "block";
} else {
target.style.display = "none";
}
}
Here is the problem when I check the validation it throws up this error
  1. Line 243, Column 51: there is no attribute "onClick". value="Show_Second_Branch" onClick="toggle('toggle', this);" />
    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. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).
    This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.
    How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash.
Has anyone got any ideas how I can fix this.
__________________
This was my latest holiday in
Please login or register to view this content. Registration is FREE
South Africa.
This was my favorite adventure holiday in
Please login or register to view this content. Registration is FREE
scorpioserve is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-12-2009, 12:16 PM Re: Code Help
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
onclick
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-12-2009, 02:41 PM Re: Code Help
Super Talker

Posts: 116
Name: Paul
Location: South Africa
Trades: 0
Quote:
Originally Posted by chrishirst View Post
onclick
hahahaha I cannot believe that it was that simple really, are the standards just too high for validation or am I missing something I mean it still works, it just seems silly to me that they expect people to have this much knowledge about things, I must be wrong cause you seem to have fixed it no problem, so we all have to be little clones of you then to successfuly code stuff.

I will send you my mail address so you can send me a sample of dna please

Thanks so much for the help
__________________
This was my latest holiday in
Please login or register to view this content. Registration is FREE
South Africa.
This was my favorite adventure holiday in
Please login or register to view this content. Registration is FREE
scorpioserve is offline
Reply With Quote
View Public Profile
 
Old 02-12-2009, 03:49 PM Re: Code Help
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The standard for XHTML validation is that element tags and attribute names MUST be in lowercase.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 02-12-2009 at 03:50 PM..
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-12-2009, 06:05 PM Re: Code Help
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
The irony, is that the normal standard for JavaScript methods is to have them in camelCase, and although JavaScript is normally case sensitive, browsers have been forced to adapt in the case of events due to this funny conflict. Therefore, events can always be expressed in all lowercase, even when you don't do things inline:
Code:
window.onload = function() {/*whatever*/}
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Code Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22105 seconds with 12 queries