<?
header("Content-type: text/html; charset=windows-1251");
$link = mysql_connect('localhost','root','');
mysql_select_db('help');
session_start();
?>
<html>
<head>
<script language="Javascript">
function xmlhttpPost(strURL , id) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring(id));
}
function getquerystring(id) {
qstr = 'id=' + escape(id); // NOTE: no '?' before querystring
return qstr;
}
function updatepage(str){
document.getElementById("result").innerHTML = str;
createIndicator();
}
function createIndicator()
{
var indicator = document.getElementById('indicator');
indicator.style.display = "block";
document.getElementById("indicator").innerHTML = 'товар добавлен';
setTimeout("deleteIndicator()",1000);
}
function deleteIndicator()
{
var indicator = document.getElementById('indicator');
indicator.style.display = "none";
}
</script>
</head>
<body style="margin: 0px;">
<div id="indicator" style="position: absolute; top: 10px; left: 390px; display: none; background: #EEE;" ></div>
<TABLE WIDTH=400 BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR>
<TD WIDTH=100 valign="top">
Корзина
<div id="result"></div>
</TD>
<TD WIDTH=300>
<?
$res = mysql_query("SELECT * FROM goods");
while($v = mysql_fetch_array($res)){
echo '<P>';
echo "<form name='f".$v[0]."'>";
echo "<input value='Add' type='button' onclick='JavaScript:xmlhttpPost(\"cart.php\" , ".$v[0].")'>";
echo " ".$v[1];
echo "</form>";
echo '</P>';
}
?>
</TD>
</TR>
</TABLE>
</body>
</html>
<?
mysql_close($link);
?>