主要目的是从XSLT生成HTML复选框。我使用了两个图像,一个检查,另一个未经检查以提出解决方案。现在的问题是,当我点击任何复选框时图像被更改,它不具体。
//这是示例xslt文件
<label>
<xsl:element name="a">
<xsl:attribute name="title">
<xsl:value-of select="$dispval"></xsl:value-of>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="$check_url"></xsl:value-of>
</xsl:attribute>
<xsl:value-of select="$dispval_abbr"/>
<xsl:value-of select="$dispcount"/>
</xsl:element>
<!-- <xsl:attribute name="src">{$resource_path_prefix}images/<xsl:value-of select='blankbox.jpg'/></xsl:attribute>-->
<xsl:variable name="addresource" select="concat($resource_path_prefix,'images/blankbox.png')"/>
<img>
<xsl:attribute name="src">
<xsl:value-of select="$addresource"/>
</xsl:attribute>
<xsl:attribute name="size">12</xsl:attribute>
<xsl:attribute name="height">12</xsl:attribute>
<xsl:attribute name="id">imgClickAndChange</xsl:attribute>
<xsl:attribute name="onclick">javascript:changeImage()</xsl:attribute>
</img>
</label>
//这是javascript函数
<script type = "text/javascript">
<![CDATA[
function changeImage() {
if (document.getElementById("imgClickAndChange").src =="http://localhost:8000/V3/V3.07.9.9/images/blankbox.png")
{
document.getElementById("imgClickAndChange").src = "http://localhost:8000/V3/V3.07.9.9/images/tickbox.png";
}
else
{
document.getElementById("imgClickAndChange").src ="http://localhost:8000/V3/V3.07.9.9/images/blankbox.png";
}
}
]]>
</script>