I want to add customers to a database using JSPs, JQuery and Servlets. When a customer already exists within the database table I want to show a confirmation message (Customer already exists. Are your sure you want to add the same customer?). When Customer does not exist all the data is written into the table and there is no need to show a confirm message.
My jquery code so far:
$('#myForm').submit(function() {
var c = confirm("Customer have already. Are your sure you want to add the same customer?");
return c;
});
And my servlet:
int i = 0;
ArrayList<Customer> cus = CustomerDao.addcustomer("abc");
i = cus.size();
if(i > 0){
statement;
}else{
statement ;
}
When I click the submit button it always shows the confirmation message. I don't wanna show confirmation message when the customer does not already exist in the database.