Reputation: 5122
With jQuery 1.10.1, I have set the value of an input field as such:
$('.entry input').keyup(function () {
$('.target input').val(foo);
});
This works on the screen, but when the form is submitted, the value is lost or at least not recognized by PHP validation.
Chrome's inspector doesn't show a value at all:
The examples on http://api.jquery.com/val/ have the same behaviour, in the inspector, the updated value can't be seen.
So how can a submittable value be set via jQuery?
Upvotes: 1
Views: 102
Reputation: 469
Instead of using a input type="text"
you could use as input type="hidden"
to store your data. hidden
inputs are not visible to the user and are often used to pass data along in forms.
Upvotes: -1
Reputation: 61056
To follow up on SLaks' answer, you could enable the input on submit:
$('#myForm').submit(function() {
$(this).('.question input').removeAttr('disabled');
return true;
});
Upvotes: 1
Reputation: 887245
That's because of the disabled
attribute.
Disabled inputs are not submitted to the server.
To fix this, remove the disabled
attribute before submitting.
Upvotes: 4