Open the popup on the submit button

I have one form in JSP. I have some input fields on this page when a user enters their values ​​and then clicks the "Submit" button so that the values ​​are inserted into the database.

But my goal is that when the user clicks the submit button, one new popup will be created, and this new popup will carry these values ​​during inserted values ​​in the parent window. Example: first page: Insert.jsp and popup: Verifyinsert.jsp. Insert.jsp page 3 contains input fields, such as roll number, student name, address. The user will enter these 3 fields first on the Insert.jsp page, and then the user will click the Submit button on the Insert .jsp page, after which one new pop-up window (Verifyinsert.jsp) will be created, carrying values ​​when the user simply typed Insert.jsp and in which there is a submit button on the Verifyinsert.jsp page, and if the user clicks the "Send" button, the records will be inserted into the database, and if the "Cancel" button is clicked on Verifyinsert.jsp, then this pop-up window simply will disappear. How to do it?

Any help is greatly appreciated.

+4
source share
3 answers

Use the onSubmit event

<html> <head> <script type="text/javascript"> function greeting(){ alert("Welcome " + document.forms["frm1"]["fname"].value + "!") } </script> </head> <body> What is your name?<br /> <form name="frm1" action="submit.htm" onsubmit="greeting()"> <input type="text" name="fname" /> <input type="submit" value="Submit" /> </form> </body> </html> 
+1
source

Are you asking how to display a popup? Should there be js popup, without reloading the page or a separate browser tab? For the former, we use the jqModal library, examples . When the user clicks the submit button, you need to display this popoup. When the user clicks the "Submit" button in this pop-up menu, you need to get all the values ​​and send them to the server. There are several ways to do this too :)

0
source

Open a popup in the view of your Insert.jsp using

  window.open("../insert.jsp?param1=xx&&pram2=cc") 

You can send the parameters as appended to the URL of the new window, as shown above.

In the Verifyinsert.jsp view, you can call the parent java script usign page

 window.opener.saveValue() 

which is a javscript function on the parent page to store values ​​in the database. Close the popup after saving.

0
source

Source: https://habr.com/ru/post/1392676/


All Articles