i had made two ajax in one form but not functioning very well... can help me??
this is my html code
[HTML]<input name="matric" type="text" id="matric" onChange="showN ame(this.value) " size="15" />[/HTML]
[HTML]<select name="year" onChange="showY ear(this.value) ">[/HTML]
and this is my javascript
(1) this is for input type
(2) this is for my select type
this is my html code
[HTML]<input name="matric" type="text" id="matric" onChange="showN ame(this.value) " size="15" />[/HTML]
[HTML]<select name="year" onChange="showY ear(this.value) ">[/HTML]
and this is my javascript
(1) this is for input type
Code:
<script language="showName.js"> function showName(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="getsname.php" url=url+"?k="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("ok1").innerHTML=xmlHttp.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }// JavaScript Document </script>
Code:
<script src="selectyear.js"> // JavaScript Documentvar xmlHttp function showYear(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="getyear.php" url=url+"?q="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint2").innerHTML=xmlHttp.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } </script>
Comment