[56K WARN] using javascript to show and hide an element
Posted: Sun Dec 23, 2007 10:20 pm
OK, so I'm nearly finished with a site. However this little "bug" has been bothering me for months.
Here's my show() and hide() javascript functions.
Nothing fancy, pretty simple, straight to the point.
Here's a piece of PHP generated HTML that it's working on.
When the 'Assign Impressions' link is clicked, the form in the row beneath it is supposed to be shown. IE7 (the first image) shows it how I'd like it to be shown.
IE7:

FF 2.0.0.11

Firefox doesn't tell me of any errors or warnings in the error console, and the page almost validates (just need to turn & into &).
EDIT| Fixed the & thing.. page validates as HTML 4.01 Transitional. Opera 9.25 displays in the same manner as firefox.
Here's my show() and hide() javascript functions.
Code: Select all
function hide(el)
{
document.getElementById(el).style.display = 'none';
}
function show(el)
{
document.getElementById(el).style.display = 'inline';
}Here's a piece of PHP generated HTML that it's working on.
Code: Select all
<table width="730" cellspacing="0" cellpadding="3" border="0" style="border: solid 1px #000;">
<tr>
<td bgcolor="#1771D4" colspan="5" align="center"><strong>Banners</strong></td>
</tr>
<tr>
<td width="20" bgcolor="lightblue"><strong>#</strong></td>
<td width="550" bgcolor="lightblue"><strong>Banner</strong></td>
<td width="100" bgcolor="lightblue"><strong>Status</strong></td>
<td width="30" bgcolor="lightblue"><strong>Views</strong></td>
<td width="30" bgcolor="lightblue"><strong>Clicks</strong></td>
</tr>
<tr>
<td valign="top">1.</td>
<td valign="top"><a href="http://www.yahoo.com" target="_blank"><img src="http://www.freepsd.com/downloads/graphics/full/36.jpg" alt="" border="0" /></a><br />[<strong>0</strong> Impressions Remaining] - [<a href="javascript:void(0);" onclick="show('b_5');">Assign Impressions</a>] - [<span class="delete"><a href="worker.php?action=delete-banner&banner_id=5" onclick="return confirm('Are you sure you want to delete the banner\nhttp://www.freepsd.com/downloads/graphics/full/36.jpg?');">delete</a></span>]</td>
<td valign="top">Accepted</td>
<td valign="top" align="center">0</td>
<td valign="top" align="center">0</td>
</tr>
<tr>
<td id="b_5" colspan="5" align="center" style="display: none;"><br />
<form action="worker.php" method="post" onsubmit="return checkimps(document.getElementById('imp_value_5').value, 350);">
<input type="hidden" name="action" value="assign-impressions" />
<input type="hidden" name="banner_id" value="5" />
<p>You may assign up to <strong>350</strong> impressions<br />
Assign <input class="textform" type="text" id="imp_value_5" name="imps_to_assign" value="0" maxlength="7" size="10" /> Impressions
<input class="submit" type="submit" name="submit" value="Assign Impressions" /></p>
<p>[<a href="javascript:void(0);" onclick="hide('b_5');">nevermind</a>]</p>
</form>
</td>
</tr>
<tr>
<td colspan="5"> </td>
</tr>
</table>IE7:

FF 2.0.0.11

Firefox doesn't tell me of any errors or warnings in the error console, and the page almost validates (just need to turn & into &).
EDIT| Fixed the & thing.. page validates as HTML 4.01 Transitional. Opera 9.25 displays in the same manner as firefox.