I am trying to automatically populate multiple input text fields with the values of variables returned from SELECT query on click checkbox event. For example: the SELECT query returns Warehouse Street Address ($WarehouseStreetAdress). Then after checking the checkbox "Use the Warehouse Street Address"this address should be entered into input text field. I have the following code:
$WarehouseStreetAddress = $_POST['WarehouseStreetAddress']; ...Select query works fine...<input id="checkbox" type="checkbox"> Use Warehouse Address<br>
Street Address: <input id="StreetAddress" type="text">
$("#checkbox").change(function() {
if (this.checked) {
var StreetAddress= $WarehouseStreetAdress;
}
$("#StreetAddress").val(StreetAddress);
}
I think that you mixed PHP with Javascript..
<input id="checkbox" type="checkbox"> Use Warehouse Address<br>
Street Address: <input id="StreetAddress" type="text">
<script type="text/javascript">
$("#checkbox").change(function() {
if (this.checked) {
$("#StreetAddress").val("<?php echo $_POST['WarehouseStreetAddress'];?>");
}
})
</script>