Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Replace submit button with image when clicked

Posted on 2006-11-20
7
Medium Priority
?
231 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
[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
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 29

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 200 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 200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

636 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