form values updated with jquery are not submitted to php -
i have problem of form fields not beingness picked in $_get in php.
i have checkbox when checked fills form fields entered data. problem when info entered manually shows , when isn't doesn't.
this jquery changes values.
$("#same_as").change(function() { var delivery = $("input[name^=delivery_]"); var invoice = $("input[name^=address_]"); if ($(this).prop("checked")) { (var = 0; < delivery.length; i++) { // populate delivery fields invoice address values $(delivery[i]).val($(invoice[i]).val()); } delivery.prop("disabled", true); } else { delivery.each(function() { // empty delivery fields $(this).val(""); }); delivery.prop("disabled", false); } });
this code submits form:
$("#register_form").submit(function(e) { e.preventdefault(); $.get($(this).attr("action"), $(this).serialize(), function(data) { info = $.parsejson(data.replace("<!doctype html>", "")); console.log(data); }); });
the php simple as: (there more checks other fields)
if (isset($_get["delivery_line_1"])) echo $_get["delivery_line_1"];
when fields filled manually info sent. when fields filled checkbox function info isn't sent. unusual part when console.log()
info before ajax request made nowadays regardless.
your problem disabling fields. stop them sending data.
just hide fields or instead
php jquery html ajax
No comments:
Post a Comment