php, javascript, & xmlhttp problem
Posted: Wed Apr 25, 2007 11:25 am
I created a site that asks the user to type in a beginning date and ending date range to display a list of ip addresses and other data on another page. The data is stored in a MySQL database. When the results are displayed on the next page, each ip address displayed has its own status dynamic drop down menu. I’m trying to get these status menus to update the status value in the database once the drop down menu is clicked on, so when data does display the drop down menus load showing the status value from the database.
As of now, I am able to all this, but when I try to chance the status value with the drop down menu, nothing happens. I took a look at a few tutorials including the one on this site, but I guess I’m still confused because it’s not working. Here is my code:
thanks in advance for any help provided
As of now, I am able to all this, but when I try to chance the status value with the drop down menu, nothing happens. I took a look at a few tutorials including the one on this site, but I guess I’m still confused because it’s not working. Here is my code:
Code: Select all
<script type="text/javascript">
function HTTPObject()
{
var JXHR;
if(window.ActiveXObject)
{
//Instantiate the latest MS ActiveX Objects
if(_XML_ActiveX)
JXHR = new ActiveXObject(_XML_ActiveX);
else
{
//loops through the various versions of XMLHTTP in IE, in order of how common they are
var versions = ["MSXML2.XMLHTTP", "Microsoft.XMLHTTP", "Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0",
"Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0"];
for(var i=0; i<versions.length; i++)
{
try
{//Try and create the ActiveXObject for Internet Explorer,
//if it doesn't work switch to next version and check again.
JXHR = new ActiveXObject(versions[i]);
if(JXHR)
{
var _XML_ActiveX = versions[i];
break;
}
}
catch(e)
{
alert("problem 1");
};
};//end for loop
}//end else
}//end 1st if
//if there is no ActiveXObject available it must be firefox, opera, or something else
if(!JXHR && typeof XMLHttpRequest != 'undefined')
{
try
{
JXHR = new XMLHttpRequest();
}
catch(e)
{
alert("problem 2");
JXHR = false;
}
}//end if
else
return JXHR;
}//end function
var http = HTTPObject(); // Create the Object
var f = false;
function updateDB(urlz, ip, val)
{
if(!f && http)
{
var stuff = "ip="+ip+";val="+val;
http.open("GET", urlz + stuff, true);
f = true;
http.send(null);
}
}
</script>
</head>
<main>
<?php
………………… code
$n = ‘\n’;
print('<td align="left"><form method="post" name="a'.$ip.'" action="">'.$n.
'<select name="a'.$ip.'" onChange="updateDB(a'.$ip.', Update.php '.$ip. 'this.value)">'.$n.
'<option selected value="'.$row['Status'].'">'.$row['Status'].'</option>'.$n.
'<option value="Open">Open</option>'.$n.
'<option value="Contacted">Contacted</option>'.$n.
'<option value="Client">Client</option>'.$n.
'<option value="Closed - No Sale">Closed - No Sale</option>'.$n.
'<option value="Closed - Not Valid">Closed - Not Valid</option>'.$n.
'<option value="Closed - Not Interested">Closed - Not Interested</option>'.$n.
'<option value="Closed - No Data">Closed - No Data</option>'.$n.
'<option value="Closed - Large Company">Closed - Large Company</option>'.$n.
'</select>'.$n.'</form>'.$n..'</td>'.$n);
…………………………………. More code
?>