Note that there are some explanatory texts on larger screens.

plurals
  1. POpopulate select from other select (include jqtransform)
    primarykey
    data
    text
    <p>i have this java script:</p> <pre><code> $("#judet div.jqTransformSelectWrapper ul li a").click(function(){ var jud= $("#judetul1").val(); $.ajax({ type: "POST", url: "rental/cms/inc/ajax/cities.php", data: { 'jud': jud }, success: function (msg) { $("#oras").html(msg); }, error: function (xhr, err) { alert("readyState: " + xhr.readyState + "\nstatus: " + xhr.status); alert("responseText: " + xhr.responseText); } }); }); </code></pre> <p>and this html:</p> <pre><code>&lt;div class=" h"&gt; &lt;span class="block"&gt;Orasul&lt;/span&gt; &lt;div class="select6" id="oras"&gt; &lt;select name="oras1" id="oras1" onchange="zone1();sectorul();"&gt; &lt;/select&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; </code></pre> <p>and this php:</p> <pre><code>public function get_oras($code3) { echo "&lt;option selected='selected' value='0'&gt;Alege oras&lt;/option&gt;"; $code='PPLA'; $code2='PPLA2'; $sql="SELECT * FROM `locatii` WHERE (`feature_code`=:code OR `feature_code`=:code2) AND `admin1_code`=:code3 ORDER BY `asciiname` ASC"; $stmt = $this-&gt;dbh-&gt;prepare($sql); $stmt-&gt;bindParam(':code', $code, PDO::PARAM_STR, 30); $stmt-&gt;bindParam(':code2', $code2, PDO::PARAM_STR, 30); $stmt-&gt;bindParam(':code3', $code3, PDO::PARAM_INT); $stmt-&gt;execute(); foreach ($stmt-&gt;fetchAll(PDO::FETCH_ASSOC) as $result) { $oras[]="&lt;option value='".$result['geonameid']."'&gt;".$result['asciiname']."&lt;/option&gt;"; } return $oras; } </code></pre> <p>html for judetul:</p> <pre><code>&lt;div class=" h"&gt; &lt;span class="block"&gt;Judetul&lt;/span&gt; &lt;div class="select6" id="judet"&gt; &lt;?php $judetul=$db-&gt;get_judet(); ?&gt; &lt;select name="judetul1" id="judetul1" &gt; &lt;option selected="selected"&gt;---&lt;/option&gt; &lt;?php foreach ($judetul as $val=&gt;$k) { ?&gt; &lt;option value="&lt;?php echo $val; ?&gt;"&gt;&lt;?php echo $k; ?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; </code></pre> <p>The problem is: I need to populate oras1 when i change judetul1. When i change the judetul1 option the select oras1 don't get the values from db.</p> <p>How can I fix it?</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.
 

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