By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,447 Members | 954 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,447 IT Pros & Developers. It's quick & easy.

delete/make invisible button?

P: n/a
Hello,

I have a button which I wish to be invisible at the end of an
application. How do delete it or simply make it invisible?

Cheers

Geoff
Sep 4 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a


Geoff Cox wrote:
I have a button which I wish to be invisible at the end of an
application. How do delete it or simply make it invisible?


In the DOM as implemented in IE 5 and later, Mozilla, Netscape 6 and
later, Opera 7 and later and other modern browsers you can remove any
node by calling removeChild on its parent node e.g.
node.parentNode.removeChild(node);
thus if you have a variable button with a reference to the button
element you can do
if (button.parentNode && button.parentNode.removeChild) {
button.parentNode.removeChild(button);
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 4 '05 #2

P: n/a
On Sun, 04 Sep 2005 19:40:07 +0200, Martin Honnen <ma*******@yahoo.de>
wrote:


Geoff Cox wrote:
I have a button which I wish to be invisible at the end of an
application. How do delete it or simply make it invisible?


In the DOM as implemented in IE 5 and later, Mozilla, Netscape 6 and
later, Opera 7 and later and other modern browsers you can remove any
node by calling removeChild on its parent node e.g.
node.parentNode.removeChild(node);
thus if you have a variable button with a reference to the button
element you can do
if (button.parentNode && button.parentNode.removeChild) {
button.parentNode.removeChild(button);
}


Martin,

Can you just explain how that would apply to my button which is
created as part of the creation of a table ..

document.write("<input type='button' value='Next'
onclick='next_question()' />");

After the "Next" button is clicked at the end of the exercise and the
results are emailed to me I would like the button to become invisible
so that the user is unable to press it again.

Cheers

Geoff

Sep 4 '05 #3

P: n/a


Geoff Cox wrote:

Can you just explain how that would apply to my button which is
created as part of the creation of a table ..

document.write("<input type='button' value='Next'
onclick='next_question()' />");


Well pass the button to your function e.g.

<input type="button" onclick="next_question(this);"

and then in the function declaration you use a formal parameter

function next_question (button) {

and then wherever in the function you want to remove the button you use
the suggested code e.g.

if (button.parentNode && button.parentNode.removeChild) {
button.parentNode.removeChild(button);
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 4 '05 #4

P: n/a
On Sun, 04 Sep 2005 20:36:59 +0200, Martin Honnen <ma*******@yahoo.de>
wrote:
Well pass the button to your function e.g.

<input type="button" onclick="next_question(this);"

and then in the function declaration you use a formal parameter

function next_question (button) {

and then wherever in the function you want to remove the button you use
the suggested code e.g.

if (button.parentNode && button.parentNode.removeChild) {
button.parentNode.removeChild(button);
}


Martin,

Brilliant! Thanks that works fine - could you just say a word ot two
about the use of "this"?

Cheers

Geoff

Sep 4 '05 #5

P: n/a
Geoff Cox wrote:
[...]

Martin,

Brilliant! Thanks that works fine - could you just say a word ot two
about the use of "this"?


I think Mike Winter gets it mostly spot on here:

<URL:http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/9b041b9103b6de0f/2065870c97d74b50?tvc=1&q=How+to+understand+the+jav ascript+class+model%3F&hl=en#2065870c97d74b50>

--
Rob
Sep 4 '05 #6

P: n/a
On Mon, 05 Sep 2005 06:48:20 +1000, RobG <rg***@iinet.net.au> wrote:
Geoff Cox wrote:
[...]

Martin,

Brilliant! Thanks that works fine - could you just say a word ot two
about the use of "this"?


I think Mike Winter gets it mostly spot on here:

<URL:http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/9b041b9103b6de0f/2065870c97d74b50?tvc=1&q=How+to+understand+the+jav ascript+class+model%3F&hl=en#2065870c97d74b50>

Thanks Rob - will follow up on this - by the way one of the longest
URL's I've seen!

How do you get the link to the posting?

Cheers

Geoff
Sep 4 '05 #7

P: n/a
Geoff Cox wrote:
On Mon, 05 Sep 2005 06:48:20 +1000, RobG <rg***@iinet.net.au> wrote:

Geoff Cox wrote:
[...]
Martin,

Brilliant! Thanks that works fine - could you just say a word ot two
about the use of "this"?
I think Mike Winter gets it mostly spot on here:

<URL:http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/9b041b9103b6de0f/2065870c97d74b50?tvc=1&q=How+to+understand+the+jav ascript+class+model%3F&hl=en#2065870c97d74b50>


Thanks Rob - will follow up on this - by the way one of the longest
URL's I've seen!

Google groups links are long, but I think some references to MS
developer documentation are longer ;-)

How do you get the link to the posting?


Enclose the link in <URL: > and your news reader does the rest.

Incidentally, if you use '-- ' (that's dash dash space) on a line by
itself before your signature, those who reply to your posts with a
newsreader will have your signature automatically trimmed (which is
thought to be a good thing in general).
--
Rob
Sep 4 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.