How do I display values immediately to a table after I click a submit button in JSP and use it for furthermore functions? Because I have this simple POS system exercise wherein I need to add products and show it on a table together with the corresponding prices and quantity. After that, calculate the total price and deduct it with the inputted money and display the change. I'm not using any framework just pure JSP.
Here's a sketch that might help:
Asked
Active
Viewed 656 times
0

Kael
- 391
- 1
- 10
- 21
-
1use a form and submit to "self" or some ajax – Mar 18 '16 at 13:37
-
while submit from jsp it will submit on Servet(use form tag) and on servlet fire query to the database will help you more. – Vishal Gajera Mar 18 '16 at 13:44
-
@RC. what do you mean by submit to "self" sir? – Kael Mar 19 '16 at 11:06
-
this answer might help: http://stackoverflow.com/a/4971908/ more – Mar 19 '16 at 11:33
1 Answers
0
With jQuery you can add the on submit form, and then you have to prevent the form from submitting. Example:
$(document).on("submit", "form", function (event) {
var $form = $(this);
$.post($form.attr("action"), $form.serialize(), function (responseJson) {
//add your table here
});
event.preventDefault(); // Important! Prevents submitting the form.
});

Romy
- 272
- 2
- 11
-
but would it still display the products that should be added in the table or not? – Kael Mar 19 '16 at 11:05