Javascript xsl生成html表格,每行有一个按钮

Javascript xsl生成html表格,每行有一个按钮,javascript,html,xslt,xslt-1.0,Javascript,Html,Xslt,Xslt 1.0,我有个问题,希望有人能帮我 这是我的xsl文件的缩短部分 <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:con="http://eviware.com/soapui/config"> <xsl:output method="html" indent="yes

我有个问题,希望有人能帮我

这是我的xsl文件的缩短部分

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:con="http://eviware.com/soapui/config">
<xsl:output method="html" indent="yes" encoding="UTF-8"/>

<xsl:template match="/">

<html>
    <head>
    <script type="text/javascript">
        function anAus(id) 
        {
                    if (document.getElementById(id).style.display == 'none') 
                    { document.getElementById(id).style.display = 'block';
                } else 
                    { document.getElementById(id).style.display = 'none';}
            }
    </script>

</head>

<body>
<TABLE border="1">

<thead>
<TH>[ id ]</TH>
<TH>[ name ]</TH>
<TH>[ aktiv ]</TH>
<TH>[ result ]</TH>
<TH>[ help ]</TH>
</thead>

<tbody>
<xsl:for-each select="....." >

<TR>
    <TD><xsl:value-of select="ID" /></TD>   
    <TD><xsl:value-of select="name" /></TD> 
    <TD> <xsl:value-of select="@activated" /></TD>
    <TD><xsl:value-of select="result" /></TD>

     <!-- column 5 --- Button -->
    <xsl:variable name="button_name" select="concat('Button_',$ID)"/>
    <xsl:variable name="button_variable" select="concat('but_var',$ID)"/>

    <TD width="50" align="center"><input name="$button_name"   Type="button"   value="help" onClick="javascript:anAus('$button_variable')"/></TD>

</TR>   

<TR id="$button_variable" style="display:none">
        <TD colspan="5" >
<xsl:value-of select = "$verbesserung" /></TD>
</TR>

</tbody>
</TABLE>

函数anAus(id)
{
if(document.getElementById(id).style.display=='none')
{document.getElementById(id).style.display='block';
}否则
{document.getElementById(id).style.display='none';}
}
[id]
[姓名]
[aktiv]
[结果]
[帮助]
现在我要解释我的问题:

对于每个元素,我在html表中生成一行。每行都有 5个细胞。最后一个单元格中有一个按钮,可以展开元素的帮助行

到目前为止,我使用了一个java.script函数,它使用行obejct的elementID来更改可见性

我尝试通过元素id和 康卡特接线员。 但在我的结果表中,每个按钮都有相同的功能,只是在第一个条目行下展开“helprow”


我尝试为每个条目给出“$button\u name”和“$button\u variable”,它们是正确的。有人能找出代码中的错误吗。

试着像这样更改上一个
td

<TD width="50" align="center">
   <input name="$button_name"   Type="button"   value="help" >
      <xsl:attribute name="onclick">javascript:anAus('<xsl:value-of select="$button_variable" />')</xsl:attribute>
   </input>
</TD>
<TR style="display:none">
   <xsl:attribute name="id"><xsl:value-of select="$button_variable" /></xsl:attribute>
   <TD colspan="5" >
     <xsl:value-of select = "$verbesserung" />
   </TD>
</TR>

代码看起来没问题,问题是什么?问题是每个按钮都调用相同的功能。他们总是在第1行调用可见性以获取帮助。我查看了结果html,“$button_name”和“$button_variable”不与它们的值一起使用,而是与它们的名称一起使用。像这样:我已经更新了我的答案,现在检查它好的,这是我搜索的。Firefox23为什么不能处理这个问题?只有IE才能进行转换。@Logi您可以通过谷歌搜索: