Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 28th, 2007, 11:07 AM
Friend of Wrox
Join Date: Jun 2003
Location: Oklahoma City, Oklahoma, USA.
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default disabling submit button

I have an upload image form and that code works perfect.

My problem is I have added some javacript to disable the button after the submission. The disable will work fine but then the form will not submit and continue processing and uploading the image. I have tried a couple of different methods, I have used method 2 before and it works fine when it is not a enctype="multipart/form-data" form. Can anybody please help me resolve this.

if (isset($_POST['action_upload']) && $_POST['action_upload'] == 'Upload') {
//upload code works fine.

METHOD 1 __________
<script language="JavaScript">
function disableForm(theform) {
    return true;

<form action="upload_img.php" method="post" enctype="multipart/form-data" id="my_form" name="upload_frm">
Select Image: <input type="file" name="up_file"><br />
<input type="submit" name="action_upload" value="Upload" onclick='doSubmit(this.form, this);'>

METHOD 2 __________
<script language="JavaScript" type="text/javascript">
var clicked = false;

function doSubmit(frm, btn){
  if (clicked == false) {
    clicked = true;
    btn.disabled = true;
    btn.value='Please wait...';
     try {
        catch(e) {}

<form action="upload_img.php" method="post" enctype="multipart/form-data" id="my_form" name="upload_frm">
Select Image: <input type="file" name="up_file"><br />
<input type="button" onclick='doSubmit(this.form, this);' value="Upload" name="action_upload">

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Make a image button as default submit button toshi ASP.NET 1.0 and 1.1 Basics 1 June 1st, 2006 05:25 AM
Disabling browser's "X" button farhanzia HTML Code Clinic 4 March 23rd, 2005 01:19 PM
Disabling browser's window "X" button farhanzia Classic ASP Professional 1 July 9th, 2003 06:29 PM
Disabling browser's "X" button farhanzia Javascript 1 July 9th, 2003 10:04 AM

All times are GMT -4. The time now is 08:51 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.