This is the first article in exploring the power of javascript when called from XSLT.
XSLT is basically used to render the xml in specified format.Here the requirement is to call some javascript function when xslt is rendering the xml.
In this article we are calling javascript on page load .
Scenario : On page load we want to fill some value in text box coming coming from the property defined in the xml .So first we need to access the property value inside javascript and then on page load need to fill the value inside the textbox.
Here is the sample javascript to be used inside the sample.xsl file
<xsl:template name="picture">
<script type="text/javascript">
function myFunction()
{
var url = ']]><xsl:value-of select="substring-before(@PictureUrl, ',')" />';
var txtBox = document.getElementById('textBox');
txtBox.value = url;
}
_spBodyOnLoadFunctionNames.push("myFunction");
]]>
script>
xsl:template>
Keep watching this space for more in javascript and XSLT.If you have done something then please share.
No comments:
Post a Comment