smus Posted February 29, 2016 Share Posted February 29, 2016 Let's pretend, there's a <div> on a page. There's a usual HTML form inside it that sends information to another php-file. By default, the visibility of the div is hidden, and the click on the button makes it visible. The question is how to close the form (i.e. hide the div) using a button or <a> element on the div, WITHOUT the sending data to php-file. In other words, how to close this <div> as if it is usual popup-window, without changes? Link to comment Share on other sites More sharing options...
davej Posted February 29, 2016 Share Posted February 29, 2016 preventDefault just as you would if the form failed to validate, although that may not even be necessary. http://www.w3schools.com/jsref/event_preventdefault.asp Link to comment Share on other sites More sharing options...
dsonesuk Posted February 29, 2016 Share Posted February 29, 2016 In some browsers using a button element in a form will submit it. If you wish to close it witout submitting place it outside of form within div. It can be text close or close image x in top left corner, then force it to hide parent element or element with id or class to its normal state. 1 Link to comment Share on other sites More sharing options...
smus Posted March 1, 2016 Author Share Posted March 1, 2016 In some browsers using a button element in a form will submit it. If you wish to close it witout submitting place it outside of form within div. It can be text close or close image x in top left corner, then force it to hide parent element or element with id or class to its normal state. Yes, it works, thanks! Just transferred the same button out of the form. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now