Note that there are some explanatory texts on larger screens.

plurals
  1. POaccording to two inputes populate select option with ajax and php
    primarykey
    data
    text
    <p>I have the following code....</p> <pre><code>&lt;form action=""&gt; &lt;select class="input-xlarge required" id="inputGender" name="inputGender"&gt; &lt;option value=""&gt;select&lt;/option&gt; &lt;option value="m"&gt;male&lt;/option&gt; &lt;option value="w"&gt;female&lt;/option&gt; &lt;/select&gt; &lt;input type="text" class="input" id="DOB" name="DOB"&gt; &lt;select class="input-xlarge" id="inputWeight" name="inputWeight"&gt; &lt;option value=""&gt;select&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" name="action" value="Book" /&gt; &lt;/form&gt; </code></pre> <p>the data.php file I have generated this JSON file, only one file after calculating the two parameter passed... DOB and inputGender... </p> <pre><code>[{"ID":"1", "desc":"(12)"},{"ID":"2", "desc":"(5)"},{"ID":"6", "desc":"(15)"}] </code></pre> <p>the jquery code I have is...</p> <pre><code>$('#inputGender', '#DOB').change(function(){ $.ajax({ type: "POST", url: "data.php", data: { gender: $('#inputGender').val() dob: $('#DOB').val() }, }).done(function( msg ) { var wcs = $.parseJSON(msg); console.log(wcs); $('#inputWeight').html(''); $('#inputWeight').append('&lt;option value=""&gt;Select&lt;/option&gt;'); $.each(wcs[$(this).val()], function() { $persons.append("&lt;option value=" + this.ID_wcl + "&gt;" + this.wcl_desc + "&lt;/option&gt;"); }); }); }); ); </code></pre> <p>I have new code ...see below...some idea why this is not working too?</p> <pre><code>$('#inputGender', '#DOB').change(function(){ $.ajax({ type: "POST", url: "data.php", data: { gender: $('#inputGender').val() dob: $('#DOB').val() }, dataType: 'json', }).done(function( msg ) { var wcs = $.parseJSON(msg); console.log(wcs); $('#inputWeight').html(''); $('#inputWeight').append('&lt;option value=""&gt;'+'&lt;?=_('[Select]')?&gt;'+'&lt;/option&gt;'); $.each(wcs, function(){ $wc=$(this); $('#inputWeight').append('&lt;option '+selected+' value="'+$wc[0].ID_wcl+'"&gt;'+$wc[0].wcl_desc+'&lt;/option&gt;'); }) }) }) </code></pre>
    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.
 

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