Jump to content

[SOLVED] Disable Submit button


jaymc

Recommended Posts

I want to run some javascript on my index page to monitor every submit button so that when its pressed it disables so a user can keep clicking it

 

I know I can do this using an ONCLICK, but I dont want to add this to every submit button

 

I want to put it in my master .js file to apply to any submit button on the page

Link to comment
https://forums.phpfreaks.com/topic/118066-solved-disable-submit-button/
Share on other sites

You would still need to have this in a submit button:

<input type="submit" name="submit" id="submit" onclick="javascript: disableSubmit(this);" />

 

Then have the appropriate javascript. But you would need to specify it in each one, as far as I know.

I want to run some javascript on my index page to monitor every submit button so that when its pressed it disables so a user can keep clicking it

 

I know I can do this using an ONCLICK, but I dont want to add this to every submit button

 

I want to put it in my master .js file to apply to any submit button on the page

 

Well, like vikramkeet.singla said, you can filter out the submits by CSS class.  It's easiest to use jQuery for this:

$(".yourClassName").click(function()
{
   //do whatever you want here
});

 

So, give your submits a class to replace 'yourClassName' and fill out the body of the onclick callback function.  That will attach that onclick callback to every element of that class.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.