Note that there are some explanatory texts on larger screens.

plurals
  1. POajax php jquery mobile select menu
    primarykey
    data
    text
    <p>On the same page I have an area to add a patient and a separate patient select menu. If a patient is added, I would like the select menu to show this new patient without refreshing the page.</p> <p>The select menu is originally populated with:</p> <pre><code>&lt;?php $result = mysql_query("SELECT * FROM `patients` WHERE `company_id` = " . $user_data['company_id'] . " ORDER BY `patient_firstname`"); while($row = mysql_fetch_array($result)) { echo '&lt;option value="' . $row['patient_id'] . '"&gt;' . $row['patient_firstname'] . ' ' . $row['patient_lastname'] . '&lt;/option&gt;'; } ?&gt; </code></pre> <p>When the select menu is used the input fields first_name, last_name, &amp; dob are populated using:</p> <pre><code>$('#patientselect').live('change', function() { $.ajax({ url : 'patientget.php', type : 'POST', dataType: 'json', data : $('#patientform').serialize(), success : function( data ) { for(var id in data) { $(id).val( data[id] ); } } }); }); </code></pre> <p>which retrieves the information from the patientget.php:</p> <pre><code>$patientId = $_POST['patientselect']; // Selected Patient Id $result = mysql_query("SELECT `patient_id`, `patient_firstname`, `patient_lastname`, `patient_dob` FROM `patients` WHERE `patient_id` = $patientId"); $row = mysql_fetch_assoc($result); $patientId = $row['patient_id']; $patientFirstName = $row['patient_firstname']; $patientLastName = $row['patient_lastname']; $patientDob = $row['patient_dob']; $arr = array( 'input#patient_id' =&gt; $patientId, 'input#patient_firstname' =&gt; $patientFirstName, 'input#patient_lastname' =&gt; $patientLastName, 'input#patient_dob' =&gt; $patientDob); echo json_encode( $arr ); ?&gt; </code></pre> <p>This is my first post, so please let me if I need to provide more/clearer information.</p> <p>Thank in advance!! Adam</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload