delete/make invisible button?

G

Geoff Cox

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
 
M

Martin Honnen

Geoff said:
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);
}
 
G

Geoff Cox

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
 
M

Martin Honnen

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);
}
 
G

Geoff Cox

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
 
R

RobG

Geoff said:
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...avascript+class+model?&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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top