Jump to content

[SOLVED] Help 2 identify part of script


Voodoo Jai

Recommended Posts

I have found a script that I want to use but I want it tpo hide the tables row and then show it if the icon is clicked, the reverse of what it does now. I can see which part does this but dont know how to reverse it.

 

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>
Show hide row
</title>
    
<script type="text/javascript">
function poorman_toggle(id)
{
var tr = document.getElementById(id);
if (tr==null) { return; }
var bExpand = tr.style.display == '';
tr.style.display = (bExpand ? 'none' : '');
}

function poorman_changeimage(id, sMinus, sPlus)
{
var img = document.getElementById(id);
if (img!=null)
{
    var bExpand = img.src.indexOf(sPlus) >= 0;
	if (!bExpand)
		img.src = sPlus;
	else
		img.src = sMinus;
}
}

function Toggle_trGrpHeader1()
{
    poorman_changeimage('trGrpHeader1_Img', 'images/toggleDLminus.gif', 'images/toggleDLplus.gif');
    poorman_toggle('trRow1');
}
</script>
    
</head>

<body>
<div align="center">
<table width="650" border="1">
<tr id="trGrpHeader1">
   <td colspan="4">
   <span onClick="javascript:Toggle_trGrpHeader1();">
   <img src="images/toggleDLminus.gif" name="trGrpHeader1_Img" width="21" height="23" id="trGrpHeader1_Img"/>Header for row 1	</span>   </td>
</tr>
<tr id="trRow1">
   <td width="150">  Hello</td>
   <td width="100" class="number">10</td>
   <td width="200" class="number">1999-11-17 00:00:00</td>
   <td width="200" class="number">1999-12-15 00:00:00</td>
</tr>
</table>
</div>
</body>
</html>

 

I think that this is the code which show or hides the rows

 

function poorman_toggle(id)
{
var tr = document.getElementById(id);
if (tr==null) { return; }
var bExpand = tr.style.display == '';
tr.style.display = (bExpand ? 'none' : '');
}

 

could someone please explain it to me.

 

Many thanks

 

VoodooJai

Link to comment
https://forums.phpfreaks.com/topic/129751-solved-help-2-identify-part-of-script/
Share on other sites

just to help you a bit on your way

 

the following code

tr.style.display =  'none';

does the following

<tr style="display:none"></tr>

 

it sets the style

 

to do the reverse you could remove the style attribute

 

 

oh and one thing this function

function poorman_toggle(id)
{
   var tr = document.getElementById(id);
   if (tr==null) { return; }
   var bExpand = tr.style.display == '';
   tr.style.display = (bExpand ? 'none' : '');
}

 

the bExpand boolean has no value in the function so it will always set the style.display='none'

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.