Solved

disable the submit button when clicked

Posted on 2003-11-07
10
1,484 Views
Last Modified: 2008-03-17
Hi all,
  I have a form where I want the submit button to be disabled when the user has click on it. This is because the process is quite long and I want to avoid the impatient users from clicking on it again...

In my form I have some javascript validations exemple
<form blabla on submit validation form...>
When the submit button is click, the form is being validated if all good then the process begins. But before returning to the next page it's quite long like I said.. so can I do something like

<input type="submit" name="go" value="save" onclick="javascript:<disable my button at this point"> ?

Thanks for the answer

0
Comment
Question by:DaDMan
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 4

Expert Comment

by:intrwrks
ID: 9703841
Try this out:

<input type="submit" name="go" value="save" onclick="javascript:this.setAttribute('disabled','true');">
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9703849
<input type="submit" name="go" value="save" onclick="this.disabled=true;">

be sure to re-enable the button if your javascript validations finds an error

0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9703861
and the re-enable would be

function validation(){
...... all your validation crap .....

.......... whoa somethings wrong .........
 alert('You idiot you filled out the form wrong. Do it again');
 document.yourFormName.go.disabled=false;


}

0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Author Comment

by:DaDMan
ID: 9703986
Hey guys your on the spot. This is what I want but I have a problem now... the button is disable but does not submit anything.. just stand there.. disabled!! :-)

Any ideas?
0
 
LVL 1

Author Comment

by:DaDMan
ID: 9703998
and this is for both method you've offered...
0
 
LVL 10

Accepted Solution

by:
Bustarooms earned 50 total points
ID: 9704000
in that case i would move it

<form name="yourform" onsubmit="this.go.disabled=true;return validation();">
0
 
LVL 25

Expert Comment

by:devic
ID: 9704035
try this:
============
<input type="submit" name="go" value="save" onclick="this.disabled=true;this.form.submit();">
0
 
LVL 1

Author Comment

by:DaDMan
ID: 9704047
yeah man!! right on.

Thanks alot

0
 

Expert Comment

by:kahkaha
ID: 14855924
but there is a specific problem with the code
<input type="submit" name="go" value="save" onclick="this.disabled=true;this.form.submit();">

this arises when you control the variable go, for example with PHP. Its value comes null or zero. thats why if you check the form's submittal by checking the button's value, PHP does not understand naturally that the form is submitted. if the button is disabled when submitting, its value transmits as zero or null
0
 
LVL 25

Expert Comment

by:devic
ID: 14855989
hi kahkaha,

then maybe this one:
=================
<form action=http://www.sembel.net/tools/q.php>
      <input type=text name=kuku value=hurra>
      <input type="submit" name="go" value="save" onclick="this.onclick=function(){return false};this.form.submit();">
</form>


btw, you need open a new question.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question