Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Following on from my comments, here's an example that takes the values from 2 selects, and submits an ajax call when both are filled in</p> <pre><code>// Notice the arguments are gone at the moment function showUser() { // Retrieve values from the selects var u = document.getElementByID('userSelect').value; var g = document.getElementByID('groupSelect').value; if (u=="" || g == "") { document.getElementById("txtHint").innerHTML=""; return; } 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("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getuser.php?u="+u+"&amp;g="+g,true); xmlhttp.send(); } </code></pre> <p>And then the basic form</p> <pre><code>&lt;form&gt; &lt;select name="users" id="userSelect" onchange="showUser()"&gt; &lt;option value=""&gt;Select a person:&lt;/option&gt; &lt;option value="1"&gt;Peter Griffin&lt;/option&gt; &lt;option value="2"&gt;Lois Griffin&lt;/option&gt; &lt;option value="3"&gt;Glenn Quagmire&lt;/option&gt; &lt;option value="4"&gt;Joseph Swanson&lt;/option&gt; &lt;/select&gt; &lt;select name="groups" id="groupSelect" onchange="showUser()"&gt; &lt;option value=""&gt;Select a group:&lt;/option&gt; &lt;option value="a"&gt;Aerosmith&lt;/option&gt; &lt;option value="k"&gt;Kiss&lt;/option&gt; &lt;option value="l"&gt;Led Zeppelin&lt;/option&gt; &lt;option value="m"&gt;Metallica&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; </code></pre> <p>This is not a fantastic option though, and as mentioned would recommend that you into using a framework such as jQuery ( <a href="http://jquery.com/" rel="nofollow">http://jquery.com/</a> ) as you will be able to spend more time on the logic rather than ensuring browser compatibility</p> <p>However you go about it though, it doesn't hurt to experiment so just give some things a try and see what happens (so long as you aren't deleting live data, anyway)</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.
    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