Hi Guys, just a quick question. I notice that the javascript 'for' function is not working when it is put to use in xslt file. I'm trying to create a simple gallery using Jquery fade in features. My script code is looking somewhat like this:
This has to do with escaping the < characters in JavaScript- you can wrap your script content in a CDATA Section to fix this, e.g.:
<script type="text/javascript"><![CDATA[
var i=0;
for (i=0;i<=5;i++)
{
document.write("The number is " + i);
document.write("<br />");
}]]>
</script>
But if you don't need to dynamically write any of the JavaScript, it'd be much better to have it in a separate file and include it with a standard <script src="..."> element...
javascript "for" function not working?
Hi Guys, just a quick question. I notice that the javascript 'for' function is not working when it is put to use in xslt file. I'm trying to create a simple gallery using Jquery fade in features. My script code is looking somewhat like this:
<!--Repetitive JavaScript--> <script> { $("#imgjq1").click(function () { $("#imgreal2").hide(); $("#imgreal3").hide(); $("#imgreal4").hide(); $("#imgreal5").hide(); $("#imgreal6").hide(); $("#imgreal7").hide(); $("#imgreal8").hide(); $("#imgreal9").hide(); $("#Dum").hide(); $("#imgreal1").fadeIn(300, function () { }); return false; }); } { $("#imgjq2").click(function () { $("#imgreal1").hide(); $("#imgreal3").hide(); $("#imgreal4").hide(); $("#imgreal5").hide(); $("#imgreal6").hide(); $("#imgreal7").hide(); $("#imgreal8").hide(); $("#imgreal9").hide(); $("#Dum").hide(); $("#imgreal2").fadeIn(300, function () { }); return false; }); } <!--- And So on.....---->
Which I guess should be able to be simplified by using the javascript 'for' function:
But even a simple javascript code as:
<script type="text/javascript"> var i=0; for (i=0;i<=5;i++) { document.write("The number is " + i); document.write("<br />"); } </script>
Gives xslt an error, while putting it in the master template doesn't make it work either.
Any intake on this issue or even a better approach to do this?
Hi,
Just a wild guess here, but did you try by specifying the script language? so:
<script language="JavaScript" type="text/javascript">
Cheers,
Michael.
Hi D-au,
This has to do with escaping the < characters in JavaScript- you can wrap your script content in a CDATA Section to fix this, e.g.:
But if you don't need to dynamically write any of the JavaScript, it'd be much better to have it in a separate file and include it with a standard <script src="..."> element...
/Chriztian
And with arrays you can use "for(var item in array)". That way you don't need to use the less or greater than signs.
is working on a reply...