I've got two disabled input fields (city and state) that are calculated automatically when a third field is filled out (zip code) in a form, the relevant parts of which are:
<form method="post" name="myemailform" action="submit.php">
<input type="text" name="home_address_city" id="home_address_city" disabled>
<input type="text" name="home_address_state" id="home_address_state" disabled>
<input type="submit" name="Submit" id="submit_button">
</form>
I'm then taking the form data and submitting it via ajax to a PHP script that emails it:
$(function(){
$('form').on('submit', function(e){
e.preventDefault();
$.ajax({
type: $(this).attr('method'),
url: $(this).attr('action'),
data: $(this).serialize()
});
});
});
The PHP then grabs everything as follows:
extract($_POST, EXTR_PREFIX_SAME, "extr");
And should be outputting it in the email body as follows:
$email_body = "City:\t$home_address_city\n"."State:\t$home_address_state\n";
These disabled
fields were previously filled out manually and they were being sent in the email without problem. Since disabling them, they are not being sent in the email but everything else is otherwise working. The values do get sent if I remove disabled
or replace it with readonly
. (Using readonly
instead was considered and rejected because it allows you to focus on the field and select the text, and the client doesn't want the user interacting with the fields at all.)
So how do I pass the values of the disabled
input fields to the PHP script?