tanuja_goturi
09-23-2005, 05:11 AM
hi,
is it possible to assign a value to an xsl variable in a javascript function
i have a set of radio buttons....of the same group...
radio 1
radio 2
suppose the xsl variable is
<xsl:variable name="selOption"/>
when radio 1 is selected the value of selOption should be radio1
if radio 2 is selected the value of selOption should be radio2
based on the value of selOption variable, i need to display a table....
is this possible in xsl? if so how? Please help me...
Thanks in advance.
Khalid Ali
09-23-2005, 11:25 AM
there is no way you can communicate to and from xsl to JavaScript
sheila
09-24-2005, 01:28 PM
Basically, you need to load the XSL stylesheet into an object and use the stylesheet's DOM to locate and change the value of the parameter. I only know how to do it in from ASP file using VBScript (see below) but it should be possible to edit/translate this to meet your needs:
Dim oStyle, oSource, xslFile, xmlFile, newData, selectNode, oParam
' Create the XSL object
set oStyle = server.createobject(MSXML2.DOMDocument.3.0)
oStyle.async = false
oStyle.validateonparse = true
' Say where the XSL stylesheet is located
xslFile = replace(server.mappath("/"), "\", "/") & "stylesheet.xsl"
' Load the stylesheet
oStyle.load xslFile
' Prepare the data (specificImageID) that you wish to pass
newData = "'" & specificImageID & "'"
' This expression will be used to locate a parameter, called imageID,
that already exists in your stylesheet
selectNode = "/xsl:stylesheet/xsl:param[@name='imageID']"
' Pass data to XSL file
set oParam = oStyle.selectSingleNode(selectNode)
oParam.setAttribute "select", newData
' Create an XML object
set oSource = server.createobject(MSXML2.DOMDocument.3.0)
oSource.async = false
oSource.validateonparse = true
' Say where the XML file is located
xmlFile = replace(server.mappath("/"), "\", "/") & "pictures.xml"
' Load the stylesheet
oSource.load xmlFile
' Transform the XML using the now modified stylesheet
response.write oSource.TransformNode(oStyle)
Obviously, in your case the parameter is called selOption rather than imageID. Hope this helps.