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
https://forums.phpfreaks.com/topic/81723-solved-onsubmit-showhide/
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>

change your input type from "button" to "submit"

 

currently is:

 

<div id="submitButton">
<input type="button" value="submit" onclick="mySubmit()">
</div>

 

would need to be:

 

<div id="submitButton">
<input type="submit" value="submit" onclick="mySubmit()">
</div>

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.