Solved

Replace submit button with image when clicked

Posted on 2006-11-20
7
224 Views
Last Modified: 2008-02-01
Can someone come up with a short JS that changes a form's submit button to an image when it's clicked?

I'd like to display an animated gif progress bar which would be displayed where the submit button was after the user submit the form.
0
Comment
Question by:cbradstreet
7 Comments
 
LVL 17

Expert Comment

by:gops1
ID: 17984318
Check this out:


<html>
      <head>
            <title>Script Demo</title>
            <script language="JavaScript">
                  function swapMe(){
                        document.getElementById('imgT').style.display="inline";
                        document.getElementById('sbmit').style.display="none";
                  }
            </script>
      </head>
<body>
<form name="temp" onsubmit="alert('Check your Button')">
      <input id="sbmit" type="submit" value="Submit Me" onClick="javascript:swapMe();"><img style="display:none" id="imgT" src="max.jpg">
</form>
</body>
</html>
0
 
LVL 28

Expert Comment

by:Pravin Asar
ID: 17984412
<form name="f1">
<input type="image" src="image1.jpg" onclick="this.disabled = true;">
</form>

0
 

Author Comment

by:cbradstreet
ID: 17984608
Hmm ... this *doesn't* seem to do the trick ... ;-)

<html>
<head>

<script language="JavaScript">
function swapMe(){
document.getElementById('imgT').style.display="inline";
document.getElementById('sbmit').style.display="none";
}
</script>

</head>

<body>

<form name="temp">
<input id="sbmit" type="submit" value="Submit Me" onClick="javascript:swapMe();"><img style="display:none" id="imgT" src="http://www.listmedia.com/graphics/progress-bar.gif">
</form>

</body>
</html>

Ideally, I want a regulat submit button, and then when user clicks the button the progress-bar.gif image appears in place of the button while my script processes the page and then proceeds to the next page.
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 50 total points
ID: 17986221
How about this:

<html>
<head>
<title>Zvonko &#42;</title>
</head>
<body>
<form name="temp">
<input id="sbmit" type="submit" value="Submit Me" onClick="this.style.display='none';document.images.imgT.style.display='';"><img style="display:none" name="imgT" src="http://www.listmedia.com/graphics/progress-bar.gif">
</form>
</body>
</html>


0
 
LVL 3

Assisted Solution

by:viveksg
viveksg earned 50 total points
ID: 17993327


<html>
<head>
<title>Zvonko &#42;</title>
<script>
function fn_Submit()
{
   document.getElementById('sbmit').style.display = 'none';
   document.getElementById('imgT').style.display = 'block';

   return true;
}
</script>
</head>
<body>
<form name="temp">
<input id="sbmit" type="submit" value="Submit Me" onClick="return fn_Submit()">
<img style="display:none" name="imgT" src="http://www.listmedia.com/graphics/progress-bar.gif">
</form>
</body>
</html>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now