Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved the problem. The function should look like:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { var sector = document.getElementById("conflictos1_id_sector_actividad"); var id_sub = sector.options[sector.selectedIndex].value; { $.ajax ({ type: "POST", url: '&lt;?php echo url_for('conflictos/subsector'); ?&gt;'+ '?id=' + id_sub, cache: false, data: "id_sub="+ id_sub, success: function(data) { // alert(data);// its show my returned value $("#conflictos1_id_subsector_actividad").html(data);// but it does not select the value of dropdown list. } }); } $("#conflictos1_id_sector_actividad").change(function() { var id_sub = $(this).val(); if(id_sub != '') { $.ajax ({ type: "POST", url: '&lt;?php echo url_for('conflictos/subsector'); ?&gt;'+ '?id=' + id_sub, cache: false, data: "id_sub="+ id_sub, success: function(data) { $("#conflictos1_id_subsector_actividad").html(data);// but it does not select the value of dropdown list. } }); } else { $("#conflictos1_id_subsector_actividad").html("&lt;option value=''&gt;-- No se ha seleccionado subsector --&lt;/option&gt;"); } return false; }); }); &lt;/script&gt; </code></pre> <p>The same function is now executed when the document is loaded. Now I've the better answer here: <a href="https://stackoverflow.com/questions/20385422/symfony-1-4-how-i-can-retrieve-the-selected-value-with-ajaxs-function-in-selec">Symfony 1.4: How I can retrieve the selected value with AJAX&#39;s function in select dependent?</a></p>
    singulars
    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