|
|
Back
Home
|
Add to Cart with JavaScript: |
JavaScript
<script language=javascript><!--
function addtoBasket(ID,Name) {
var cart_basket;
var qty;
for (var i=0; i<self.document.nowsee.length; i++){
if
(self.document.nowsee.elements[i].name == ID){
qty=self.document.nowsee.elements[i].value;
}
}
cart_basket = " " + GetCookie('ezcart3');
if (qty > 0) {
if (cart_basket != ' null'){
document.cookie="ezcart3"+"=" + cart_basket +
"|" + ID + "," + qty + "; path=/;";
}else{
document.cookie="ezcart3"+"=" + ID + "," +
qty + "; path=/;";
}
if (qty==1){
alert
(qty + " " + Name + " has been added to your order");
}else{
alert
(qty + " " + Name + " have been added to your order");
}
}
return;
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return
getCookieVal (j);
i =
document.cookie.indexOf(" ", i) + 1;
if (i == 0)
break;
}
return 'null';
}
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr =
document.cookie.length;
return
unescape(document.cookie.substring(offset, endstr));
}
//-->
</script>
Explanation :
Copy this java script to your
webpage |
Quantity Field
<FORM NAME="nowsee"
>
<p >Quantity</p>
<p><input
type="text"
name="126"
size="5"></p>
</form>
Explanation :
<FORM NAME="nowsee">
This
html tag MUST be copied before the qty field
<input
type="text"
name="126" size="5"> This
field must be copied between the form tags and the 126 is the
Product ID
</form>
This html tab MUST be copied after the qty field |
Add Button
<p><a href="javascript:addtoBasket('5','Samsung
SVO644A 6.4GB 10ms 540 ')">
<b>Add
to Cart</b></a></p>
Explanation :
addtoBasket('5','Samsung
SVO644A 6.4GB 10ms 540 ')"
The "5",
is the product ID or Internal code.
The "Samsung...."
is a Small legend to be used in the alert message. |
Checkout Button
<p><a href="/cgi-bin/nowsee/cart41/cart?cart=ai"><b>Order
Form</b></a></p>
Explanation :
Use this link to go direct to the
"View Cart" page |
|