/    Sign up×
Community /Pin to ProfileBookmark

Change visibility

Hi,

I have a button, when you click on it it should become invisible. I’ve tried this:

[code=php]<input type=”button” style=”visibility:visible” onclick=”this.style.visibility=hidden”>

//and

<input type=”button” style=”visibility:visible” onclick=”this.style.visibility=’hidden'”>[/code]

But it doesn’t seem to work.

Thanks in advance,

Neil

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@PittimannApr 25.2004 — Hi neil9999! ?

Your example would only work, if hidden was a variable defined before. Just make it like that with single quotes around the hidden:

<input type="button" style="visibility:visible" onclick="this.style.visibility='hidden'">

Cheers - Pit
Copy linkTweet thisAlerts:
@neil9999authorApr 25.2004 — Thanks, it works perfectly.

Neil?
Copy linkTweet thisAlerts:
@neil9999authorApr 27.2004 — How could I do this the other way round?

[code=php]<body onload="loader()" onload="document.getElementById('but1').style.visibility='visible'">
<input type="button" value=" 1 " onclick="quiz(1)" style="visibility:hidden" id="but1">[/code]


When the document loads, but1 should become visible.

Thanks again,

Neil
Copy linkTweet thisAlerts:
@PittimannApr 27.2004 — Hi!

Provided that the two functions called in your snippet are available and ok, your code should not produce a problem in browsers understanding document.getElementById.

Cheesr - Pit
Copy linkTweet thisAlerts:
@neil9999authorApr 27.2004 — Thanks for your reply, but it still isn't working. Attatched is the whole page.

Thanks again,

Neil

[upl-file uuid=5aa355ed-6286-43e0-b0e4-1a464f5c879f size=3kB]mastermind3.txt[/upl-file]
Copy linkTweet thisAlerts:
@fredmvApr 27.2004 — The problem is that you've defined two [font=courier]onload[/font] events. You'll need to do something like this:onload="loader();document.getElementById('but1').style.visibility='visible';"
×

Success!

Help @neil9999 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,
)...