I have a problem with form submission. The form is built using Jquery and then the data is passed to another page, where I
<%String userEmail="[email protected]";%>
<script>
$form = $("<form id='frm' action='submit.jsp' method='post'>");
$form.append(" <input id='userEmail' name='userEmail' class='input' value=<%=userEmail%> type='hidden' /> ");
$form.append("Enter a barcode: ");
$form.append(" <input id='bcode' name='bcode' class='input' type='number' size='12' required/> <br/> ");
$form.append('Enter a price: ');
$form.append("<input id='price' class='input' name='price' type='number' size='12' required/> <br/></form>");
$("#form").append($form);
Then, when "Submit" button (with id="submit") is pressed:
$(".next").on("click", "#submit", function () {
$("#frm").submit();
});
</script>
Then in submit.jsp:
<%
String price = request.getParameter("price"); //problem
String barcode = request.getParameter("bcode"); //problem
String userEmail = request.getParameter("userEmail");
form frm = new form();
insRes = frm.insertEvent(price, barcode, userEmail);
%>
The problem is that I get NULL instead of "price" and "barcode". The email field is OK.
P.S. Yes, I'm very new to programming, study by myself using books and google. Searched for the similar problem here, didn't find. Sorry if I missed it.
I've serialized the form before submission, and the only thing was submitted is email. Why? Does it matter that I form the form with jquery?
I have found what was causing the problem. After a user enters a barcode and a price I check if the inputs are OK, and if they are OK, I prevent user from changing them by adding:
$("#price").attr("disabled", "disabled");
$("#bcode").attr("disabled","disabled");
When I commented those two lines, the problem was solved.
Sorry for not putting the whole code - I didn't think it matters. Thanks everyone!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments