snowdog Posted February 9, 2013 Share Posted February 9, 2013 I want the submit button to disappear after it has been clicked. Guys are too impatient and it is inputting multiple database lines. Can I use javascript to make the button disappear on click? Snowdog Link to comment https://forums.phpfreaks.com/topic/274253-java-script-help-needed-on-submit-button/ Share on other sites More sharing options...
denno020 Posted February 9, 2013 Share Posted February 9, 2013 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 Link to comment https://forums.phpfreaks.com/topic/274253-java-script-help-needed-on-submit-button/#findComment-1411402 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.