Solved

disable the submit button when clicked

Posted on 2003-11-07
10
1,497 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…
Suggested Courses

626 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