disabling submit button once clicked

  • Nem
  • Guru
  • Guru
  • No Avatar
  • Joined: 13 Feb 2004
  • Posts: 1240
  • Loc: UK
  • Status: Offline

Post July 30th, 2004, 6:54 am

how can i disable the submit button once clicked?!
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 30th, 2004, 6:54 am

  • RichB
  • Guru
  • Guru
  • User avatar
  • Joined: 17 May 2003
  • Posts: 1121
  • Loc: Boston
  • Status: Offline

Post July 30th, 2004, 8:57 am

Maybe something like this:

<input type="submit" onclick="this.disabled=true" />


or if you want to give an indication that it's processing maybe:

<input type="submit" onclick="this.disabled=true;this.value='processing'" />
  • Nem
  • Guru
  • Guru
  • No Avatar
  • Joined: 13 Feb 2004
  • Posts: 1240
  • Loc: UK
  • Status: Offline

Post July 30th, 2004, 12:40 pm

It does work, but not when i add the rest of my code in for some reason.
GSDomains.com -Click here - Packages starting from £3.69 a month. 1.5GB Space & 10GB Bandwidth.
  • Nem
  • Guru
  • Guru
  • No Avatar
  • Joined: 13 Feb 2004
  • Posts: 1240
  • Loc: UK
  • Status: Offline

Post July 30th, 2004, 12:43 pm

I mean, it does work but it does not actual process....
GSDomains.com -Click here - Packages starting from £3.69 a month. 1.5GB Space & 10GB Bandwidth.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Joined: 17 May 2003
  • Posts: 1121
  • Loc: Boston
  • Status: Offline

Post July 30th, 2004, 1:53 pm

I tested it in FireFox and didn't think to test it in IE until just now. It wouldn't work in IE until I added another line:

<input type="submit" onclick="this.disabled=true;this.value='processing';this.form.submit();" />


Hopefully, that'll do it.
  • Nem
  • Guru
  • Guru
  • No Avatar
  • Joined: 13 Feb 2004
  • Posts: 1240
  • Loc: UK
  • Status: Offline

Post July 30th, 2004, 1:57 pm

  • RichB
  • Guru
  • Guru
  • User avatar
  • Joined: 17 May 2003
  • Posts: 1121
  • Loc: Boston
  • Status: Offline

Post July 30th, 2004, 2:07 pm

Maybe try moving this.form.submit to the front:

<input type="submit" onclick="this.form.submit();this.disabled=true;this.value='processing'" />
  • Nem
  • Guru
  • Guru
  • No Avatar
  • Joined: 13 Feb 2004
  • Posts: 1240
  • Loc: UK
  • Status: Offline

Post July 30th, 2004, 2:10 pm

it will now process the form, but not disable it.

:|
GSDomains.com -Click here - Packages starting from £3.69 a month. 1.5GB Space & 10GB Bandwidth.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Joined: 17 May 2003
  • Posts: 1121
  • Loc: Boston
  • Status: Offline

Post July 30th, 2004, 2:27 pm

Hmm, while perhaps trying it from a function onsubmit would work. You could try removing the onclick entirely and adding this function insided the <head> tag:

<script type="text/javascript">
function disable(f) {
   var button = f.elements['submit'];
   button.value = "processing";
   button.disabled=true;
   return true;   
}
</script>


and then add this to the form tag:

onsubmit="disable(this)"
  • Nem
  • Guru
  • Guru
  • No Avatar
  • Joined: 13 Feb 2004
  • Posts: 1240
  • Loc: UK
  • Status: Offline

Post July 30th, 2004, 2:30 pm

no luck

*weeps*
GSDomains.com -Click here - Packages starting from £3.69 a month. 1.5GB Space & 10GB Bandwidth.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Joined: 17 May 2003
  • Posts: 1121
  • Loc: Boston
  • Status: Offline

Post July 30th, 2004, 2:36 pm

Do me a favor and try this link and see if it works for you. It's the same method that I just posted - it should just echo some nonsense after the form is submitted (a hidden field just for testing) but see if the disabling works for you because it seems to be working for me.

http://www.gotrivia.com/2.html
  • joebert
  • S.T. Manager
  • Genius
  • User avatar
  • Joined: 10 Feb 2004
  • Posts: 11000
  • Loc: Clearwater, FL
  • Status: Offline

Post July 30th, 2004, 6:21 pm

Works for me RichB, IE6 :)

*tiptoes away slowly as not to step on any toes :P *
The squeaky wheel gets the grease, but the whining wheel gets replaced.
Picksel: Ubuntu/Gnome alternative to Colorpix
  • Cafu
  • Student
  • Student
  • No Avatar
  • Joined: 15 Jul 2004
  • Posts: 97
  • Status: Offline

Post July 30th, 2004, 11:48 pm

Works here in IE6 and Netscape 7.1
  • Nem
  • Guru
  • Guru
  • No Avatar
  • Joined: 13 Feb 2004
  • Posts: 1240
  • Loc: UK
  • Status: Offline

Post July 31st, 2004, 2:58 am

works for me too *confused*.
GSDomains.com -Click here - Packages starting from £3.69 a month. 1.5GB Space & 10GB Bandwidth.
  • Nem
  • Guru
  • Guru
  • No Avatar
  • Joined: 13 Feb 2004
  • Posts: 1240
  • Loc: UK
  • Status: Offline

Post July 31st, 2004, 3:06 am

Here is some snippets of my code:

[php]
$header = "<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN >
<html>
<head>
<title>Test</title>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
<script type=text/javascript>
function disable(f) {
var button = f.elements['submit'];
button.value = 'processing';
button.disabled = 'true';
return true;
}
</script>

</head>

<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>
<div align=center>
<table width=100% height=100% border=0 cellpadding=0 cellspacing=0>
<tr>
[/php]

Then my form:

<form method='post' action='<? $PHP_SELF ?>' onsubmit='disable(this)'>
                <table width=75% border=0 cellpadding='0' cellspacing='0' bgcolor='#D4D0C8'>
                  <tr>
                    <td align=center> <table width='100%' border='0'  cellpadding='0'  cellspacing='0'  bordercolor='#000000'>
                        <tr bordercolor='#000000'  bgcolor='#D4D0C8' >
                          <td colspan='2'> <div align='center'><strong><font size='2' color='#FF0000' face='Verdana, Arial, Helvetica, sans-serif'>
              <? echo $uerror
         ?> </font></strong></div></td>
                        </tr>
                  <tr bordercolor=#000000  bgcolor=#D4D0C8 >
                          <td colspan=2>&nbsp;</td>
                        </tr>
                        <tr bordercolor=#000000  bgcolor=#D4D0C8 >
                          <td width=42%><font size=2  face=Verdana, Arial, Helvetica, sans-serif>Username</font></td>
                          <td width=58%><input name='username'  type=text  size=25 style="border-style: solid; border-width: 1px 1px 1px 1px" /></td>
                        </tr>
                        <tr bordercolor=#000000 bgcolor=#D4D0C8>
                          <td><font size=2 face='Verdana, Arial, Helvetica, sans-serif'>Password</font></td>
                          <td> <input name='password' type='text' size='25' style="border-style: solid; border-width: 1px 1px 1px 1px" /></td>
                        </tr>
                        <tr align='center' valign='middle' bordercolor='#000000' bgcolor='#D4D0C8'>
                          <td colspan='2'>&nbsp; </td>
                        </tr>
                        <tr align='center' valign='middle' bordercolor='#000000' bgcolor='#D4D0C8'>
                          <td colspan='2'><input type='submit' name='submit' value='Login' style="border-style: solid; border-width: 1px 1px 1px 1px; font-style: strong" /></td>
                        </tr>
                      </table></form>
GSDomains.com -Click here - Packages starting from £3.69 a month. 1.5GB Space & 10GB Bandwidth.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 31st, 2004, 3:06 am

Post Information

  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2009. Driven by phpBB © 2001-2009 phpBB Group.