Tuesday 15 May 2012

jquery - Putting javascript variable into xsl attribute -



jquery - Putting javascript variable into xsl attribute -

<script type="text/javascript"> var i=0; function increase() { i++; document.getelementbyid('slide').innerhtml= +i; document.getelementbyid('slidenum').innerhtml = document.getelementbyid('slide').innerhtml; } </script> <p> slide: <slide id="slide">0</slide> </p> <xsl:variable name="slidenum"> <slidenum id="slidenum">0</slidenum> </xsl:variable> <p> <xsl:variable name="imgsrcs"> <xsl:value-of select="//movie[@num='($slide)']/thumb_img"/> </xsl:variable>

here have function increment slide 1 every onclick forwards button. want set slide id imgsrcs variable says $slide onclick of forwards button go next film if possible don't know much css or javascript place larn how can create slideshow help.

assuming xslt runs outside of browser:

javascript runs when page displayed in browser, while xslt generating html before browser loads (on server side). there no way javascript have impact on xsl variables.

what can transform xml film info javascript dictionary, this:

<script type="text/javascript"> var thumbs = { <xsl:foreach select="//movie"> "<xsl:value-of select="@num"/>": "<xsl:value-of select="thumb_img"/>", </xsl:foreach> }; </script>

and update html using like:

var img=document.getelementbyid("..."); img.url = thumbs[$slide];

the code not tested, give thought how can that.

please note have check whether info needs escaped when generating javascript xml (f.e. create sure there no quotes in xml data).

javascript jquery html css xslt

No comments:

Post a Comment