php with js will it work
Posted: Fri Nov 10, 2006 5:13 am
Have look at this code: will it work?
Code: Select all
<table>
<tr>
<td class="header"><a href="#" onClick="buy('15413497'); return false;">
<img src="http://www.ticketchest.com/images/c_buy.jpg" border="0" height="18" width="95"></a></td>
</tr></table>Code: Select all
<script>
function buy(id)
{
var t = document.getElementById(id).value;
alert();
<?PHP
$cartObj = new ShoppingCart;
if(isset($_SESSION['cartItems']))
{
$cartObj -> $items = $_SESSION['cartItems'];
$cart->add_items("Apples", 5);
}
else
{
$cartObj -> $items = NULL;
$_SESSION['cartItems'] = $cartObj -> $items;
$cart->add_items("Peach", 5);
$_SESSION['cartItems'] = $cartObj -> $items;
}
?>
}
</script>