timmah1 Posted July 24, 2008 Share Posted July 24, 2008 I have a form, I'm only going to show a little part I'm just starting to learn AJAX, and I'm getting stuck <select name="plumbing" id="plumbing" onClick="plumbingUser(this.value)"> <option></option> <option value="<?php echo $row['name']; ?>"><?php echo $row['name']; ?></option><br /> </select> </td> </tr> </table></td> </tr> <tr> <td>HVAC Contractor</td> <td><table width="600" cellpadding="5" cellspacing="0"> <tr> <td width="200"> <div id="hvacHint"><b><?php echo $row9['hvac_contractor']; ?></b></div></td> <td width="200"> <select name="hvac" id="hvac" onClick="hvacUser(this.value)"> <option>--</option> <option value="an">Add New</option> <option>--</option> <option value="<?php echo $row['id']; ?>"><?php echo $row['name']; ?></option><br /> </select> Here is the part that is suppose to bring out the values var xmlHttp function hvacUser(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="getuser.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("hvacHint").innerHTML=xmlHttp.responseText } } function plumbingUser(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="getplumbing.php" url=url+"?p="+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("plumbingHint").innerHTML=xmlHttp.responseText } } The problem is, I think 'plumbingHint' is overriding the 'hvacHint' because where the hvac is suppose to show, nothing shows, but the hvac shows where plumbing is suppose to go, and nothing happens when I click on anything where the plumbing is. Can anybody shed some light on what I'm doing wrong? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/116494-anybody-help-with-this-form/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.