Note that there are some explanatory texts on larger screens.

plurals
  1. POchanging multiple dropdowns with ajax and php
    text
    copied!<p>I have a question regarding AJAX and PHP, I have a main drop down list and when the user changes it, other drop downs are supposed to be changed based on the main drop down value, to be more clear i have a quick finder part of the website i am working on, there is a pick up port(The main drop down), there is also 4 other drop downs that are supposed to be changed using AJAX and PHP when the user changes this pickup port one, does anyone have an idea how to create that, I have been working on it for like 3 days now, and not successful.</p> <p>Thanks in advance.</p> <p>I have tried this </p> <pre><code>function filter(id) { if(window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) { document.getElementById('type_filter').innerHTML = xmlhttp.responseText; document.getElementById('find-trip-dest-region').innerHTML = xmlhttp.responseText; } } xmlhttp.open('GET', 'forms/type_filter.php?id=' + id, true); xmlhttp.send(); xmlhttp.open('GET', 'forms/activity_filter.php?id=' + id, true); xmlhttp.send(); } </code></pre> <p>and also this</p> <pre><code>function filter(id) { if(window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) { document.getElementById('type_filter').innerHTML = type_filter.responseText; document.getElementById('find-trip-dest-region').innerHTML = activity_filter.responseText; } } var type_filter = xmlhttp.open('GET', 'forms/type_filter.php?id=' + id, true); xmlhttp.send(); var activity_filter = xmlhttp.open('GET', 'forms/activity_filter.php?id=' + id, true); xmlhttp.send(); } </code></pre> <p>and also tried this</p> <pre><code>function filter(id) { if(window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) { document.getElementById('type_filter').innerHTML = type_filter.xmlhttp.responseText; document.getElementById('find-trip-dest-region').innerHTML = activit_filter.xmlhttp.responseText; } } var type_filter = xmlhttp.open('GET', 'forms/type_filter.php?id=' + id, true); xmlhttp.send(); var activit_filter = xmlhttp.open('GET', 'forms/activity_filter.php?id=' + id, true); xmlhttp.send(); } </code></pre>
 

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