Form submission using Jquery: NULL is submitted

keshet

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.

EDIT:

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?

keshet

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Delayed form submission using JQuery

From Dev

Ajax form submission on a form created using jquery

From Dev

Using PHP form validation on jQuery form submission

From Dev

Modal form Submission to PHP using Jquery .ajax

From Dev

form submission using jquery.confirm

From Dev

Prevent double submission of form using jQuery

From Dev

form submission using jquery.confirm

From Dev

jquery form not gettin submitted

From Dev

Bootstrap tab Multiple form submission by using form id in jquery

From Dev

Jquery form submission is not working

From Dev

Jquery form validation and submission

From Dev

jquery form and image submission

From Dev

jquery dynamic form submission

From Dev

Form submission trouble with jQuery

From Dev

Jquery mobile form submission

From Dev

jQuery preventing form submission

From Dev

Dynamically injected form field does not get submitted while form submission

From Dev

django - prevent form submission if submitted form value is X

From Dev

django - prevent form submission if submitted form value is X

From Dev

Grails Form Submission Fails with Dynamic Fields using JQuery

From Dev

Using jQuery AJAX to call a php page on form submission

From Dev

How to confirm a form submission with Bootbox using jQuery AJAX and JSON

From Dev

jQuery - stop form submission from changing page using ajax

From Dev

Grails Form Submission Fails with Dynamic Fields using JQuery

From Dev

Don't reload page after form submission using ajax and jquery

From Dev

Form Submission not working second time after submiting using Jquery and Ajax

From Dev

Returning null after form submission

From Dev

jQuery get submitted form values

From Dev

jQuery disabled form is submitted on enter

Related Related

HotTag

Archive