Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>According to your code, you should use this in your <code>select_list.php</code> script:</p> <pre><code>$col = $_POST['col']; $wval = $_POST['wval']; // now you can use those variables to save to DB, or get some data out of DB </code></pre> <p>I assume you want to have cascade <code>&lt;select&gt;</code> elements, you should change your <code>ajaxReq()</code> function:</p> <pre><code>function ajaxReq(col, wval) { // first remove all selects that are after this one var remove = false; var next = null; // we also need to trap next select so we can fill it for (i in ar_cols) { if (ar_cols[i] == col) { remove = true; // from now on, remove lists } else if (remove) { // if ok to remove if (!next) { next = ar_cols[i]; // now we found next column to fill } if (ar_cols[i]) { // remove only non null removeLists(ar_cols[i]); } } } if(wval!='- - -' &amp;&amp; wval!='' &amp;&amp; next) { // also if there is column after to fill var request = get_XmlHttp(); var php_file = 'select_list.php'; var data_send = 'col='+col+'&amp;wval='+wval+'&amp;next='+next; // also add next param request.open("POST", php_file, true); document.getElementById(preid+col).innerHTML = 'Loadding...'; request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); request.send(data_send); request.onreadystatechange = function() { if (request.readyState==4) { // we fill next select document.getElementById(preid+next).innerHTML = request.responseText; } } } } </code></pre> <p>Your <code>select_list.php</code> should look something like this:</p> <pre><code>$col = $_POST['col']; // this is just a filter for values in next &lt;select&gt; $wval = $_POST['wval']; $next = $_POST['next']; // we need to get this param or we cannot setup next &lt;select&gt; // using $col and $wval variables get values from DB echo '&lt;select name="' . $next . '" onchange="ajaxReq(\'' . $next . '\', this.value);"&gt;'; foreach ($data as $row) { echo '&lt;option ...&gt;...&lt;/option&gt;'; // fix this to work for you } echo '&lt;/select&gt;'; </code></pre> <p>// Code changed due to bug found<br> The ajax request should contain one more parameter (<code>next</code> column) since the returned <code>&lt;select&gt;</code> should have name and onchange event prepared for next, not the currently changed.<br> Check the code above again.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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