Hello,
I have a problem with echo’d tables from php. Its a kinda hard to explain so this is the working page:
[URL=”http://www.maartenwelbergen.nl/v2/gallerij.php”] http://www.maartenwelbergen.nl/v2/gallerij.php
If you click on the + the description shows up. Again and it hides.
Now i want to have only one description open at the same time.
First i tryed to use an external javascript file but then i got the error:
[I]document.getElementById(“galTxt0”) has no properties.
I solved this problem by using onclick in the echo’d html code.
This is the html code echo’d by php:
[CODE]
for ($i=1;$i<count($ar_dirsInc);$i++) {
echo (‘
<table width=”100%” border=”0″ cellpadding=”0″ cellspacing=”0″>
<tr bgcolor=”#333333″>
<td>
<table width=”100%” height=”25″ border=”0″ cellpadding=”0″ cellspacing=”0″>
<tr>
<td bgcolor=”#333333″>’.$ar_dirsEx[$i].'</td>
<tdbgcolor=”#333333″ align=”right”>
<a style=”border:none” href=”javascript:;” onclick=”show_hide(‘galTxt’.$i.”)”>
<img src=”images/menu/gal_btn_plus.png” id=”galImg’.$i.'” width=”19″ height=”19″ border=”0″ />
</a>
</td>
</table>
</td>
</tr>
<tr id=”galTxt’.$i.'” style=”display:none”>
<td>
<table>
<tr>
<td width=”35%” align=”center”>
<img src=”admin/gallerij/’.$ar_dirsInc[$i].’/’.$ar_lastFiles[$i].'” height=”100″ />
</td>
<td width=”65%”>
‘.$textOne.’
</td>
</tr>
</table>
</td>
</tr>
</table>’);
The onclick in the images triger this function:
[CODE]
function show_hide(tblid, show) {
if (tbl = document.getElementById(tblid)) {
if (null == show) show = tbl.style.display == ‘none’;
tbl.style.display = (show ? ” : ‘none’);
}
}
I tryed to change the function to:
[CODE]var allId = document.getElementById(“*”);
for (var i=0; i<allId.length; i++) {
if (allId[i].indexOf(“getTxt”) > -1) {
if (allId[i]==tblid) {
document.getElementById(tblid).style.display = ”;
} else {
document.getElementById(allId[i]).style.display = ‘none’;
}
}
}
but i get the error:
[I]allId has no properties.
Now i’m looking for a way to let the echo’d code listen to my external javascript or to change the function so it hides the description when i open another description.
Post here or pm me if you need more code/info.
Thanks for reading.
Greetings
Gert-Jan Rebel