Hi,
I’m pulling my hair out because I have checked, checked and checked again and I cannot find the problem!!
Here’s my code…
[CODE]
<script language=”JavaScript”>
function createInstance()
{
var req = null;
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
try {
req = new ActiveXObject(“Msxml2.XMLHTTP”);
} catch (e)
{
try {
req = new ActiveXObject(“Microsoft.XMLHTTP”);
} catch (e)
{
alert(“XHR not created”);
}
}
}
return req;
};
function delcat()
{
var req = createInstance();
var cat_id = document.delcatform.delcatid.value;
var data = “action=delete_cat&cat_id=” + cat_id;
req.onreadystatechange = function()
{
if(req.readyState == 4)
{
if(req.status == 200)
{
}
else
{
alert(“Error: returned status code ” + req.status + ” ” + req.statusText);
}
}
};
req.open(“POST”, “ajax-test2.php”, true);
req.setRequestHeader(“Content-Type”, “application/x-www-form-urlencoded”);
req.send(data);
alert(data);
};
</script>
<?php
include (‘../dbconfig.php’);
$result = mysql_query(“SELECT * FROM category ORDER BY cat_id ASC”);
while ($row = mysql_fetch_array($result))
{
echo $row[‘cat_name’];
echo ‘<form name=”delcatform” method=”POST” action=””>
<input type=”text” name=”delcatid” value=”‘.$row[‘cat_id’].'” /><br />
<input type=”submit” value=”Delete Category” onClick=”delcat()”>
</form<br />’;
}
?>
I am having a few problems with trying to get three different forms to work from the one page but I’ll go into that after I have this one fixed!!…I have set it to alert the data so that I can see the information is being submitted properly. In the alert box it tells me “action=delete_cat&cat_id=undefined”.
Any help with solving would be appreciated….
thanks in advance
Smithster