Connecting Tech Pros Worldwide Forums | Help | Site Map

how to make a button disappear after it is clicked once

Newbie
 
Join Date: Mar 2007
Posts: 15
#1: Apr 11 '07
onclick="this.href='javascript:void(0)';this.disab led=1">

ive tried that, but it renders it useless and doesnt make it 'submit'

it should be able to work, but so the user cannot submit it twice if they tried to 'machine gun' type thing using their mouse to submit repeatedly

I guess this can be considered an HTML problem not PHP but im using it in php in the sense that the button clicked triggers the form to load and it has data that is used in php to put into the database

= )

Newbie
 
Join Date: Apr 2007
Posts: 18
#2: Apr 11 '07

re: how to make a button disappear after it is clicked once


Quote:

Originally Posted by mdburton

onclick="this.href='javascript:void(0)';this.disab led=1">

ive tried that, but it renders it useless and doesnt make it 'submit'

it should be able to work, but so the user cannot submit it twice if they tried to 'machine gun' type thing using their mouse to submit repeatedly

I guess this can be considered an HTML problem not PHP but im using it in php in the sense that the button clicked triggers the form to load and it has data that is used in php to put into the database

= )

This is definitely a JavaScript question.

As this can only be achieved via JavaScript, you don't have to worry about the href attribute.

So do something like:

[HTML]onclick="this.onclick=function() { return false; };"[/HTML]

If the onclick returns false then the browser will stop the link/form from being submitted.

So after the first click, the onclick will look like:

[HTML]onclick="return false;"[/HTML]

So next clicks will not trigger the form submission, or link submission etc.
Reply