Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<html> <head> <title>AJAX Example</title> <script type="text/javascript"> //global variable var selArr = new Array(); /*** from http://jibbering.com/2002/4/httprequest.html an article by Jim Ley***/ var xmlhttp /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; } } /*** Blame me if anything goes wrong below ;) ***/ function getData(val) { if(val.length == 0) return; url="server4.php?pet=" + val; xmlhttp.open("GET",url,true); xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); xmlhttp.setRequestHeader("Content-Type", "text/xml"); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { selArr = xmlhttp.responseText.split(","); mkSel2(); } } xmlhttp.send(null); } function mkSel2(){ var selObj = document.forms['f1'].elements['sel2']; selObj.options.length = 0; for(var j = 0; j < selArr.length; j++){ selObj[selObj.options.length] = new Option(selArr[j], selArr[j]); } } </script> </head> <body> <form name="f1"> <select name="sel1" onchange="getData(this.value)"> <option value = "">Pick One <option value = "cats">Cats <option value = "dogs">Dogs <option value = "horses">Horses </select> <p> <select name="sel2"> <option value = "">Pick One </select> </p> </form> </body> </html>
<?php $phpArr = array("cats" => 'Pick One,Fluffy,Tiger,Garfield', "dogs" => 'Pick One,Spot,Skip,Woff', "horses" => 'Pick One,Ed,Dolly,Boots'); if(isset($_GET['pet'])){ echo $phpArr[$_GET['pet']]; } ?>