/    Sign up×
Community /Pin to ProfileBookmark

bug in Firefox???

Hello,
I have a js function that is triggered with the onclick event. In particular, there is a <tr> in a table that is shown when the user clicks on the “Show” button.

In HTML I have:

[code]
<tr> <td>
<img id=”myimage” src=”css/images/show.png” onclick=”javascript:HideShow(‘myrow’);”/>
</td>
</tr><tr id=”myrow” style=”display:none”>
<td>Hello all!
</td>
</tr>
[/code]

and the JS part is:

[code]
<script type=”text/javascript”>
function HideShow(myVar)
{
if (document.getElementById(myVar).style.display == ‘none’)
{
document.getElementById(myVar).style.display = ‘inline’
}
else
{
document.getElementById(myVar).style.display = ‘none’
}
}
</script>
[/code]

The function works fine, that is, when the user clicks on the image, the tr appears and then, if the user clicks again, it disappears… BUT all these work perfectly with IE, whereas in Firefox, the contents of the tr appear and disappear when the image is clicked, however, when the user clicks twice, the “Hello world” data disappears, but a blank row remains…And, if you do that again and again, I end up with as much blank rows as the times that I click the button for the data to disappear…

Is this something like a bug? Can I do anything else?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@zvoneMar 11.2008 — try document.getElementById(myVar).style.display = 'block'
Copy linkTweet thisAlerts:
@KorMar 12.2008 — In FF (and in all the DOM compliant browsers) the positive display of a table or a table element is [I]neither[/I] "inline" [I]nor[/I] "block". See:

http://www.w3.org/TR/REC-CSS2/tables.html#q2

Fortunately, the positive display is to be achieved in a simple crossbrowser way by assigning a default empty value:
<i>
</i>function HideShow(myVar){
var row=document.getElementById(myVar);
row.style.display=row.style.display=='none'?'':'none';
}
×

Success!

Help @ktsirig spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...