/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
############################ html file ############################ <script language=javascript> var xmlHttp_1 = null; var objDiv_1 = null; var htmlContents_1 = null; function createXMLHttpRequest_1() { if (window.ActiveXObject) { xmlHttp_1 = new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest) { xmlHttp_1 = new XMLHttpRequest(); } } function handleStateChange_1() { if(xmlHttp_1.readyState == 4) { if(xmlHttp_1.status == 200) { htmlContents_1 = xmlHttp_1.responseText; objDiv_1.innerHTML = htmlContents_1; } } } function getContents_1(url, divv) { objDiv_1 = document.getElementById(divv); createXMLHttpRequest_1(); xmlHttp_1.onreadystatechange = handleStateChange_1; xmlHttp_1.open("GET", url, true); xmlHttp_1.send(null); } function send(name, layer) { getContents_1("./idchk.php?id="+name,layer); } </script> <form> <input name=n type=text size=10> <input type=button value=Input onClick=send(this.form.n.value,'layer1')> </form> <!-- result --> <div ID="layer1"></div> ############################ php file (idchk.php) ############################ <? echo "You can use <b>".$_GET['id']."</b>"; ?>