Hello,
I have a dropdown list populated from XML. Now, based on the selection on the
dropdown the onclick event is expected to display the description of the
function. The idea is to get the index of the selected list item and display
the corresponding description node from the XML. I have tried several ways to
pass the value to the xsl tags. I tried Concatenating the string "<xsl:value-of
select=""functiontitle/funcdef[" & i & "]/funcdesc"" />". This did not work
(obviously... xsl didn't like it).
I also tried to define a namespace and declare a variable and trying to solve
it by passing a variable to it. I don't know what I maybe missing, cause I am
getting an error "Namespace 'http://www.w3.org/XML/1998/namespace' does not
contain any functions."
I would really appreciate any help on this one! Thanks in Advance!
The original XSL Goes like this:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="dropdown-button">
<h2>User Defined Functions Dropdown List</h2>
< script language="VBScript" >
function SetVal()
for i=1 to 6
if UCAse(document.getElementById(i).selected) = "TRUE" then
document.form1.functionName.value=document.getElementById(i).innerHTML
document.form1.functiondescription.value =
"<xsl:value-of select="functiontitle/funcdef[i]/funcdesc" />"
Exit For
End if
Next
End function
</msxsl:script>
<form name="form1">
<table border = "0">
<tr>
<td>
<b>Select a function</b>
</td>
<td>
<select name="functionList" id="first">
<xsl:variable name="my-var">
<xsl:value-of select = "1"/>
</xsl:variable>
<xsl:for-each select="functiontitle/funcdef">
<xsl:variable name="funcid">
<xsl:value-of select = "id"/>
</xsl:variable>
<option id="{$funcid}">
<xsl:value-of select="funcname"/>
</option>
</xsl:for-each>
</select>
</td>
<td>
<input id="second" name="Details" type ="button" value="Click here
for Details!" onclick="SetVal()"/>
</td>
</tr>
<table id="third" name="hiddentable" border="1">
<div>
<tr>
<td>
<input id="fourth" type="text" name="functionName" />
</td>
<td>
<input id="fifth" type="text" name="functiondescription" />
</td>
</tr>
</div>
</table>
</table>
</form>
</xsl:template>
<xsl:template match="/">
<html>
<body>
<xsl:call-template name="dropdown-button" />
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The XSL with Namespace and variable goes like this:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:vb_user="http://www.w3.org/XML/1998/namespace">
<xsl:template name="dropdown-button">
<h2>User Defined Functions Dropdown List</h2>
<msxsl:script language="VBScript" implements-prefix="vb_user">
function SetVal()
for i=1 to 6
if UCAse(document.getElementById(i).selected) = "TRUE" then
document.form1.functionName.value=document.getElementById(i).innerHTML
Set SetVal = i
Exit For
End if
Next
End function
</msxsl:script>
<form name="form1">
<table border = "0">
<tr>
<td>
<b>Select a function</b>
</td>
<td>
<select name="functionList" id="first">
<xsl:variable name="my-var">
<xsl:value-of select = "1"/>
</xsl:variable>
<xsl:for-each select="functiontitle/funcdef">
<xsl:variable name="funcid">
<xsl:value-of select = "id"/>
</xsl:variable>
<option id="{$funcid}">
<xsl:value-of select="funcname"/>
</option>
</xsl:for-each>
</select>
</td>
<td>
<input id="second" name="Details" type ="button" value="Click here
for Details!" onclick="SetVal()"/>
<xsl:variable name="test">
<xsl:value-of select="vb_user:SetVal()"/>
</xsl:variable>
</td>
</tr>
<table id="third" name="hiddentable" border="1">
<div>
<tr>
<td>
<input id="fourth" type="text" name="functionName" />
</td>
<td>
<input id="fifth" type="text" name="functiondescription"
value="{$test}" />
</td>
</tr>
</div>
</table>
</table>
</form>
</xsl:template>
</xsl:stylesheet>
The XML is like this:
<?xml-stylesheet type="text/xsl" href="todropdown.xsl"?>
<functiontitle>
<funcdef >
<id>1</id>
<funcname >flNVGLogin</funcname>
<funcdesc >This function logs into CMM app</funcdesc>
</funcdef>
<funcdef >
<id>2</id>
<funcname >flVLDLogin</funcname>
<funcdesc >This validates login page</funcdesc>
</funcdef>
<funcdef >
<id>3</id>
<funcname >flNVGCloseBrowser</funcname>
<funcdesc >This function closes CMM app</funcdesc>
</funcdef>
<funcdef >
<id>4</id>
<funcname >flVLDCloseBrowser</funcname>
<funcdesc >This function navigates and closes the browser</funcdesc>
</funcdef>
<funcdef >
<id>5</id>
<funcname >flNVGPopup</funcname>
<funcdesc >This function navigates thru the popup menu</funcdesc>
</funcdef>
<funcdef >
<id>6</id>
<funcname >flVLDPopup</funcname>
<funcdesc >This function validates the popup menu items</funcdesc>
</funcdef>
</functiontitle>
Thanks!
Anu Nistala
anistala(_at_)ercot(_dot_)com
512 248 4535 (office)
Nodal Integration Test Automation
Electric Reliability Council of Texas, Inc.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--