Jump to content

[SOLVED] onsubmit, show/hide


dkirk

Recommended Posts

I have a form in which I am trying to hide the submit button once it has been clicked and replace it with a gif image. The code that I am trying is below but I cannot get it to work. Right now both elements show up at the same time. Please help!

 

<script type="javascript">

function onSubmit(){

document.getElementById('submitButton').style.display = "none";

document.getElementById('progressBar').style.display = "block";

}

</script>

 

<form action="..." onSubmit="return onSubmit()">

.....

<div id="submitButton">

<input type="button" value="submit">

</div>

<div id="progressBar" style="display: hidden">

<img src="progressbar.gif">

</div>

 

</form>

Link to comment
Share on other sites

<script language="javascript">
function mySubmit()
{
document.getElementById('submitButton').style.display = "none";
document.getElementById('progressBar').style.display = "block";
}
</script>

<form action="">
<div id="submitButton">
<input type="button" value="submit" onclick="mySubmit()">
</div>
<div id="progressBar" style="display:none">
<img src="progressbar.gif">
</div>

</form>

Link to comment
Share on other sites

finally got it straight with a different approach but thanks for the help.

 

<html>

<head>

<title>Submit Hider</title>

 

<script type="text/javascript">

function onSubmitButton(){

        document.getElementById("submitButtonDiv").style.display = "none";

 

if (navigator.appName == "Microsoft Internet Explorer") {

document.getElementById("progressBar").innerHTML = "";

document.getElementById("progressBar").style.display = "block";

document.getElementById("progressBar").innerHTML = "<img src='progressbar.gif' alt='Progress Bar'>";

} else {

document.getElementById("progressBar").style.display = "block";

}

}

</script>

<body>

<form action="" onsubmit="return onSubmitButton()">

<div id="submitButtonDiv">

  <input type="submit" value="submit">

</div>

<div id="progressBar" style="display:none">

  <img src="progressbar.gif" alt="Progress Bar">

</div>

 

</form>

</body>

</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.