dynamically showing/hiding a row

Here should go questions about transforming XML with XSLT and FOP.
syxxzonz
Posts: 5
Joined: Sat Jun 04, 2005 1:31 am

dynamically showing/hiding a row

Post by syxxzonz »

I have the following:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes" />
<xsl:template match="/database">
<html>
<head>
<title>clients</title>
<script type="text/javascript">
<![CDATA[
function show_hide()
{
var st1;

if(button1.value=="Hide Name")
{
st1="none";
button1.value="Show Name";
}
else
{
st1="block";
button1.value="Hide Name";
}

var tb1 = document.getElementById("main");
var rows = tb1.getElementsByTagName("tr");

for (var row=0; row<rows.length; row++)
{
var cels = rows[row].getElementsByTagName("td");
cels[0].style.display=st1;
}

}

function show_hide_tran()
{
if(button2.value=="Hide Transactions")
{

button2.value="Display Transactions";
}
else
{
button2.value="Hide Transactions";
}
}

]]>

</script>
</head>
<body>
<input type="button" id="button1" value="Hide Name" onClick="show_hide()"/>
<input type="button" id="button2" value="Hide Transactions" onClick="show_hide_tran()"/>
<table id="main" border="3" cellspacing="1" cellpadding="1">
<xsl:apply-templates select="element"/>
</table>
</body>
</html>
</xsl:template>

<xsl:template match="element">
<xsl:apply-templates select="customer" />
<xsl:apply-templates select="transaction" />
</xsl:template>

<xsl:template match="customer">
<tr>
<td><xsl:apply-templates select="name"/></td>
<td><xsl:apply-templates select="order"/></td>
<td><xsl:apply-templates select="price"/></td>
</tr>
</xsl:template>

<xsl:template match="transaction">
<tr class="special">
<td><xsl:apply-templates select="day"/></td>
<td colspan="2"><xsl:apply-templates select="time"/></td>
</tr>
</xsl:template>

</xsl:stylesheet>


---------------------------------------

what I want to do is with the click of a button (button2) I want to show/hide the rows that have the class name "special". I want to do this through a function that is called by the click of button2. Any help will be greatly appreciated. thank you!!

Renato