owdy-88
06-03-2009, 11:06 AM
Hi Guys,
I had a problem I posted here last night. I was able to get a solution right away, which was great. I've just realized that a section of my assignment requires some form of DOM, as well as JaveScript. I've implemented some DOM into my script but I seem to be having the same problems I was having last night:
The third column shows the information by default. I want to change my script so that it's initially HIDDEN
The 'show/hide' function only functions for the top row. If I press the show/hide button on any other row it only applies to the top code
Here's my script:
<script language="javascript" type="text/javascript">
function showHideDiv()
{
var divstyle = new String();
divstyle = document.getElementById("div1").style.visibility;
if(divstyle.toLowerCase()=="hidden" || divstyle == "")
{
document.getElementById("div1").style.visibility = "visible";
document.getElementById('btn1').value='Hide';
}
else
{
document.getElementById("div1").style.visibility = "hidden";
document.getElementById('btn1').value='Show';
}
}
</script>
and here's my XSL:
<body>
<h2>BUSS315 DHTML Assignment - Beaus CD Collection</h2>
<table border="1">
<tr bgcolor="#99CCCC">
<th>Artist:</th>
<th>Album Title:</th>
<th>More Information:</th>
</tr>
<xsl:for-each select="CATALOG/CD">
<tr>
<td><xsl:value-of select="ARTIST"/></td>
<td><xsl:value-of select="TITLE"/></td>
<div id="div1">
<td>
<ul>
<li>Country: <xsl:value-of select="COUNTRY"/></li>
<li>Record Company: <xsl:value-of select="COMPANY"/></li>
<li>Price: <xsl:value-of select="PRICE"/></li>
<li>Year of Release: <xsl:value-of select="YEAR"/></li>
</ul>
<input type="button" value="show hide div" onclick="showHideDiv()" id='btn1' />
</td>
</div>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Any help would, once again, be appreciated greatly. What I want is pretty simple: the 'show/hide' button in that third column, and for the information to appear and disappear accordingly when the button is clicked. Also, as previously stated, I want the information in the third column initially hidden, so all that appears when the page is loaded is the show/hide button.
Cheers.
I had a problem I posted here last night. I was able to get a solution right away, which was great. I've just realized that a section of my assignment requires some form of DOM, as well as JaveScript. I've implemented some DOM into my script but I seem to be having the same problems I was having last night:
The third column shows the information by default. I want to change my script so that it's initially HIDDEN
The 'show/hide' function only functions for the top row. If I press the show/hide button on any other row it only applies to the top code
Here's my script:
<script language="javascript" type="text/javascript">
function showHideDiv()
{
var divstyle = new String();
divstyle = document.getElementById("div1").style.visibility;
if(divstyle.toLowerCase()=="hidden" || divstyle == "")
{
document.getElementById("div1").style.visibility = "visible";
document.getElementById('btn1').value='Hide';
}
else
{
document.getElementById("div1").style.visibility = "hidden";
document.getElementById('btn1').value='Show';
}
}
</script>
and here's my XSL:
<body>
<h2>BUSS315 DHTML Assignment - Beaus CD Collection</h2>
<table border="1">
<tr bgcolor="#99CCCC">
<th>Artist:</th>
<th>Album Title:</th>
<th>More Information:</th>
</tr>
<xsl:for-each select="CATALOG/CD">
<tr>
<td><xsl:value-of select="ARTIST"/></td>
<td><xsl:value-of select="TITLE"/></td>
<div id="div1">
<td>
<ul>
<li>Country: <xsl:value-of select="COUNTRY"/></li>
<li>Record Company: <xsl:value-of select="COMPANY"/></li>
<li>Price: <xsl:value-of select="PRICE"/></li>
<li>Year of Release: <xsl:value-of select="YEAR"/></li>
</ul>
<input type="button" value="show hide div" onclick="showHideDiv()" id='btn1' />
</td>
</div>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Any help would, once again, be appreciated greatly. What I want is pretty simple: the 'show/hide' button in that third column, and for the information to appear and disappear accordingly when the button is clicked. Also, as previously stated, I want the information in the third column initially hidden, so all that appears when the page is loaded is the show/hide button.
Cheers.