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 -
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
|