Note that there are some explanatory texts on larger screens.

plurals
  1. POStatic dropdown using AJAX,PHP
    text
    copied!<p>singleselect.html</p> <pre><code>&lt;html&gt; &lt;script&gt; function singleselect(str) { var xmlhttp; if(str.length == 0) { document.getElementById("sing").innerHTML=""; return; } if(window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhtttp.onreadystatechange = function() { if(xmlhttp.readyState == 4) { document.getElementById("sing").innerHTML = xmlhttp.responsetext; } } xmlhttp.open("POST","singleselect.php?s=" +str,true); xmlhttp.send(); } &lt;/script&gt; &lt;style&gt; div { font-family:verdana; font-size:13px; margin-left:400px; margin-top:100px; } &lt;/style&gt; &lt;body&gt; &lt;div&gt; Select a country : &lt;select onchange="document(this.value)"&gt; &lt;option&gt;Select a country&lt;/option&gt; &lt;option value="0"&gt;INDIA&lt;/option&gt; &lt;option value="1"&gt;United States of America&lt;/option&gt; &lt;option value="2"&gt;United Kingdom&lt;/option&gt; &lt;option value="3"&gt;Australia&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div id="sing"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>singleselect.php</p> <pre><code>&lt;?php $store[0] = "Please select a country"; $store[1] = "Andhra Pradesh"; $store[2] = "New York"; $store[3] = "London"; $store[4] = "Austraila"; $s = $_REQUEST['s']; ?&gt; </code></pre> <p>When I click on a country, a list of states related to a country should be displayed and i want to be done static in php but using database. Since I am jQuery and AJAX. I need your guidance.</p>
 

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