0

I currently have a HTML form where the user will select an Aircraft from a dropdown. What I want to be able to do is then get the value for what they have selected and store it to a variable to then be able to do a select query from the database to select all the info for that aircraft without them having to click a button or refresh the page. I currently have it so that on update it is writing the value to a hidden texbox using java but from what I can tell I cannot find a way to then store this to PHP as one is client side and the other is server side.

The following is the dropdown and hidden texbox:

<select id="ac">
     <option>-- Select --</option>
     <?php while ($row1 = mysqli_fetch_array($result5)):;?>
     <option value = "<?php echo $row1['Rego'] ?>"><?php echo 
     $row1['Rego'] ?></option>
     <?php endwhile; ?>
</select>

<input type="text" name="hidden" id="hide">

This is the Javascript for the on update

<script type="text/javascript">
        $(document).ready(function() {
            $('#ac').on('change', function() {
                var aircraft = $(this).val();
                document.getElementById('hide').value = aircraft;
            });
        });
</script>

I want to be able to have the var aircraft stored to a variable I can then use in a MySQL select query such as SELECT * FROM Aircraft WHERE Rego = VARIABLE

1 Answers1

0

You cannot convert a Javascript variable to php variable, But you can do vice-versa. If you want to convert then you should use Ajax technique.

lifeisbeautiful
  • 817
  • 1
  • 8
  • 18