0

I have a query about web development. Don't have development knowledge and trying build a web application.

The requirement is:
When the user clicks a submit button after enter data in 2-3 html input textboxes, I would like to pop-up a confirmation dialog based on results from some java code e.g. if the data entered is already existing in server, I would like to ask: "Hey! this data is already there. Are you sure you wanted merge the input with existing data?".

I am not sure how I can do it. I am using Java, Tomcat, Eclipse, JSP, HTML, Javascript in my application. I know I can invoke javascript functions on click of button, but how to generate a confirmation dialog based on some processing of the input data, and based on confirmation, go ahead with full processing.

vjy
  • 1,184
  • 1
  • 10
  • 24
Micro
  • 1
  • 1
    This can be done using Ajax. Here's a good starting point to learn about it: [How to use Servlets and Ajax?](http://stackoverflow.com/q/4112686/1065197). It would be better to first learn the basics about web development: [design patterns on web applications](http://stackoverflow.com/q/3541077/1065197), specially MVC, [How to avoid Java Code in JSP-Files?](http://stackoverflow.com/q/3177733/1065197) and [How do servlets work? Instantiation, session variables and multithreading](http://stackoverflow.com/questions/3106452/how-do-servlets-work-instantiation-session-variables-and-multithreading) – Luiggi Mendoza Jun 25 '13 at 20:55
  • Also check out http://directwebremoting.org/dwr/index.html – mplungjan Jun 25 '13 at 21:09
  • @mplungjan I agree that a framework can help to leverage this job. Still IMO it would be better learning the concepts and how to apply them and then use any tool/framework to help with this job. – Luiggi Mendoza Jun 25 '13 at 22:15

1 Answers1

-1

To do conformation in javascript, you use the prompt function. You would do the following

function askForConformation()  {
     var ask = prompt("Are you sure that you want to do this?");

     // making sure for both cases
     if(ask === "Y" || ask === "y") {
        // do whatever you need
     }
     else {
        // do whatever else
     }
}
user2277872
  • 2,963
  • 1
  • 21
  • 22
  • 1
    This will just prompt the user for a yes/no action. If you read the question carefully, OP wants/needs to do this based on a request to the data before being saved (that should be done using ajax). – Luiggi Mendoza Jun 25 '13 at 20:59