calorisplanitia
asked on
hide show table rows cross browser
I need a javascript & css way to hide or show a row of a table dynamically dreated table.ASAP
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
A modification if u can tell me
the aboce solution works fine , but can i use a plus minus image to toggle rows between visible & invisible instead of different buttons
Like if it is visible the plus image show else minus image shows
the aboce solution works fine , but can i use a plus minus image to toggle rows between visible & invisible instead of different buttons
Like if it is visible the plus image show else minus image shows
try something like this
<script>
function ShowHide(tr, btn) {
var flag;
flag = tr.style.display == '' ? 2 : 1;
if ( flag == 1 ) {
tr.style.display = '';
btn.value = 'Hide';
}
else if ( flag == 2 ) {
tr.style.display = 'none';
btn.value = 'Show';
}
}
</script>
<table border="1">
<tr id="tr1">
<td>1, 1</td>
<td>1, 2</td>
</tr>
<tr id="tr2">
<td>2, 1</td>
<td>2, 2</td>
</tr>
</table>
<br>
<input type="button" value="Hide" onclick="ShowHide(document .getElemen tById('tr1 '), this)">
<br>
<input type="button" value="Hide" onclick="ShowHide(document .getElemen tById('tr2 '), this)">
<script>
function ShowHide(tr, btn) {
var flag;
flag = tr.style.display == '' ? 2 : 1;
if ( flag == 1 ) {
tr.style.display = '';
btn.value = 'Hide';
}
else if ( flag == 2 ) {
tr.style.display = 'none';
btn.value = 'Show';
}
}
</script>
<table border="1">
<tr id="tr1">
<td>1, 1</td>
<td>1, 2</td>
</tr>
<tr id="tr2">
<td>2, 1</td>
<td>2, 2</td>
</tr>
</table>
<br>
<input type="button" value="Hide" onclick="ShowHide(document
<br>
<input type="button" value="Hide" onclick="ShowHide(document
ASKER
Thanks a lot.
No problem
ASKER
Thankx hongjun