Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to work with multiple ajax?
    primarykey
    data
    text
    <p>i am using ajax to get data in Date Label, bt it is not working. Details() function is working , but showDate() is stucked. How i get the data in <strong>dt id</strong>??</p> <pre><code>&lt;label&gt;&lt;b&gt;From&lt;/b&gt;&lt;/label&gt; &lt;select id="f" onchange="Details();"&gt;&lt;?php echo $coptions; ?&gt;&lt;/select&gt; &lt;label&gt;&lt;b&gt;Destination&lt;/b&gt;&lt;/label&gt; &lt;select id="d" onchange="Details();"&gt;&lt;?php echo $coptions; ?&gt;&lt;/select&gt; &lt;label&gt;&lt;b&gt;Flight Name&lt;/b&gt;&lt;/label&gt; &lt;select id="list" onchange="showDate();" &gt;&lt;/select&gt; &lt;label&gt;&lt;b&gt;Date&lt;/b&gt;&lt;/label&gt; &lt;select id="dt" &gt;&lt;/select&gt; &lt;button &gt;Go&lt;/button&gt; </code></pre> <p>here is my ajax functions:</p> <pre><code>function Details() { var xmlhttp; var fname = document.getElementById("f").value; var dname = document.getElementById("d").value; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { document.getElementById("list").innerHTML=xmlhttp.responseText; showDate(); } } xmlhttp.open("GET","route.php?q="+fname+"&amp;w="+dname,true); xmlhttp.send(); //loadDetails(); } function showDate() { var xmlhttp; var ex=document.getElementById("list"); var id=ex[ex.selectedIndex].id; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("dt").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","schdl2.php?f="+id,true); xmlhttp.send(); //loadDetails(); } </code></pre> <p>my schdl2.php page is like this:</p> <pre><code>&lt;?php session_start(); require_once("dbconnect.php"); $fl=$_REQUEST['f']; $sql= "SELECT date FROM schedule where flight='$f1'"; $rslt = mysql_query($sql); $foptions=""; while ($row=mysql_fetch_array($rslt)) { $rd=$row["date"]; $foptions.="&lt;option&gt;$rd&lt;option&gt;"; } echo $foptions; ?&gt; </code></pre> <p>is there is any efficient way??</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.
 

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