Jump to content

Java Script help needed on Submit button


snowdog

Recommended Posts

You can do it by calling a javascript function using the onsubmit event in the form tag. The function then adds a class to the button which hides it (display:none;). Very much like this:

 

HTML

<form action="#" method ="POST" onsubmit="return hideButton()">

<!-- other form stuff-->

<input type="submit" name="sumit" id="submit" value="submit"/>
</form>

 

Javascript

function hideButton(){
document.getElementById("submit").className="hide";

return false;
}

 

CSS

.hide{
display:none;
}

 

I've got the return false in the javascript function because I didn't want my browser to be trying to submit a page when I was testing. This will need to return true, otherwise the form will never submit :).

 

Hope that helps.

 

Denno

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.