JeremyA Posted November 6, 2008 Share Posted November 6, 2008 I am having a problem with the following code. I have successfully loaded some of my php files based on the users selection. However on the checkbox options I am having trouble. When a user clicks on newphone or newcomputer it loads their respective .php files. However if either one of the checkboxes are selected I want it to load a building.php file. The code below works because of the alert which triggers the xmlhttp.status of = 200. If the alert is not in there the call fails because the xmlhttp.status is not set. Maybe I am looking at this problem all wrong. //Create a boolean variable to check for a valid Internet Explorer instance. var xmlhttp = false; var NewComputer = false; var NewPhone = false; //Check if we are using IE. try { //If the Javascript version is greater than 5. xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); //alert ("IE for reals? Upgrade please!"); } catch (e) { //If not, then use the older active x object. try { //If we are using Internet Explorer. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //alert ("IE for reals? Upgrade please!"); } catch (E) { //Else we must be using a non-IE browser. xmlhttp = false; } } //If we are using a non-IE browser, create a javascript instance of the object. if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { xmlhttp = new XMLHttpRequest(); //alert ("You are not using Microsoft Internet Explorer"); } function MakeRequest(ServerPage, objID) { var obj = document.getElementById(objID); xmlhttp.open("GET", ServerPage); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { obj.innerHTML = xmlhttp.responseText; } } xmlhttp.send(null) } function EvaluateNeedsPhone(MyForm){ if (MyForm.NeedsPhone.checked){ MakeRequest('New Phone.php','3'); NewPhone = true; } else{ MakeRequest('BlankPage.html','3'); NewPhone = false; } LoadBuilding(); } function EvaluateNeedsComputer(MyForm){ if (MyForm.NeedsComputer.checked){ NewComputer = true; MakeRequest('New Computer.php','2'); } else{ //This will remove area's that are deselected NewComputer = false; MakeRequest('BlankPage.html','2'); } LoadBuilding(); } function LoadBuilding(){ if (NewPhone == true || NewComputer == true){ alert("Please fill out the building"); MakeRequest('Building.php','4'); } else{ alert("You no longer need to fill out your building"); MakeRequest('BlankPage.html','4'); } } Quote Link to comment Share on other sites More sharing options...
JeremyA Posted November 6, 2008 Author Share Posted November 6, 2008 Here are some more of the files. Thanks in advance for your help. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.