...

View Full Version : Help with shopping cart?????



HiEverybody
07-12-2004, 08:40 PM
My friend gets the error message "object expected" when he clicks on the add to shopping cart link.

What is he doing wrong

Please Help???

Here is the code for the order page:

Code:

<html>
<head>
<title>Easy Credit Online Shopping</title>
<SCRIPT LANGUAGE = Javascript>

</SCRIPT>

</head>

<body bgcolor="#FFFFFF" text="#000000">
<div align="center">
<p><font size="5"><b>Welcome to the Easy Credit Online Shopping Site</b></font>
</p>
<p>&nbsp;</p>
</div>
<hr>
<p align="center">Press 'V' to view your Shopping cart or click <a href="cart.htm">here</a></p>
<table width="70%" border="1" align = "center">
<tr>
<td width="24%" height="37">T-Shirt</td>
<td width="66%" height="37" align="left" valign="middle">
<p align="left">Lime Green T-Shirt with Orange Easy Credit Logo - Small</p>
<p ><a href="javascriptlace('T-Shirt - Small')" align="left">Add to Shopping Cart</a></p>
</td>
<td width="10%" height="37">R29.50</td>
</tr>
<tr>
<td width="24%" height="37">T-Shirt</td>
<td width="66%" height="37" align="left" valign="middle">
<p align="left">Lime Green T-Shirt with Orange Easy Credit Logo -Medium</p>
<p ><a href="javascriptlace('T-Shirt - Medium')"align="left">Add to Shopping Cart</a></p>
</td>
<td width="10%" height="37">R34.50</td>
</tr>
<tr>
<td width="24%" height="37">T-Shirt</td>
<td width="66%" align="left" valign="middle">
<p align="left">Lime Green T-Shirt with Orange Easy Credit Logo - Large</p>
<p ><a href="javascriptlace('T-Shirt - Large')"align="left">Add to Shopping Cart</a></p>
</td>
<td width="10%">R39.50</td>
</tr>
<tr>
<td width="24%" height="37">Capp</td>
<td width="66%" align="left" valign="middle">
<p align="left">Adjustable Lime Green Cap with Orange Easy Credit Logo</p>
<p ><a href="javascriptlace('Lime Green Cap')"align="left">Add to Shopping Cart</a></p>
</td>
<td width="10%">R18.75</td>
</tr>
<tr>
<td width="24%" height="37">Capp</td>
<td width="66%" align="left" valign="middle">
<p align="left">Adjustable Orange Cap with Lime Green Cap Easy Credit Logo</p>
<p ><a href="javascriptlace('Orange Cap')"align="left">Add to Shopping Cart</a></p>
</td>
<td width="10%">R18.75</td>
</tr>
<tr>
<td width="24%" height="37">Easy Credit Teddy Bear</td>
<td width="66%" align="left" valign="middle">
<p align="left">25cm Tall Lime Green Teddy Bear with Orange T-shirt</p>
<p ><a href="javascriptlace('Teddy Bear')"align="left">Add to Shopping Cart</a></p>
</td>
<td width="10%">R66.50</td>
</tr>
</table>
<p align="center">E-mail us for more information: <a href="mailto:easycredit@hotmail.com">easycredit@hotmail.com</a></p>
</body>
</html>

Here is the code for the viewing of the shopping cart page:

Code:

<html>
<head>
<title>Easy Credit Online Shopping</title>
<SCRIPT LANGUAGE = Javascript>

var items_string = "";

function place(new_item)
{
items_string = items_string + "xxx" + new_item;
document.cookie = "items=" + escape(items_string);
}

"items=xxxT-Shirt - Small;xxxT-Shirt - Medium;xxxT-Shirt - Large;xxxLime Green Cap;xxxOrange Cap;xxxTeddy Bear;"
whole_items_cookie = "items=xxxT-Shirt - SmallxxxT-Shirt - MediumxxxT-Shirt - LargexxxLime Green CapxxxOrange CapxxxTeddy Bear";

if (whole_items_cookie !="")
{
items_array = whole_items_cookie.split("xxx");
items_array[0] = "items=";
items_array[1] = "T-Shirt - Small";
items_array[2] = "T-Shirt - Medium";
items_array[3] = "T-Shirt - Large";
items_array[4] = "Lime Green Cap";
items_array[5] = "Orange Cap";
items_array[6] = "Teddy Bear";

}

</script>


</head>

<body bgcolor="#FFFFFF" text="#000000">

<SCRIPT LANGUAGE = Javascript>

if(items_array != "")
{
for (i=1; i < items_array.length; i++)
{
document.write("<h3>" + items_array[i] + "</h3>");
}
}
</script>

</body>

</html>

sad69
07-12-2004, 09:51 PM
Well it looks like 'Add to Shopping Cart' is a link. The 'webpage' it points to is: javascriptlace('Orange Cap'). (found in the href attribute...).

Now that looks somewhat bizarre right off the bat. So now that leads us to believe that your friend is trying to execute some Javascript, possibly trying to make a Javascript function call? Now what's the name of this function?

Is it: javascriptlace or lace?

In the href attribute, to make a Javascript call, you need to use the following prefix:
javascript:xxx(...)


<a href="javascript:lace('Orange Cap')" align="left">Add to Shopping Cart</a>


The alternative method is to do the following:


<a href="#" onclick="lace('Orange Cap');" align="left">Add to Shopping Cart</a>


Either way, after studying the provided code, there were no functions found. You have to create the function (whether it's javascriptlace or lace) before you can make a call to it.

Hopefully that helps, post back if you're still having problems. Also, wrap any and all code in [ code ][ /code ] tags (no spaces) and ensure proper indenting is applied (for our ease of reading..)

Sadiq.

HiEverybody
07-13-2004, 01:27 AM
It had to be place and not lace.

He has almost completed his shopping cart program.

Thanx for the tip on the [code] tags!

Thank You for your trouble and sorry about not using code tags

Cheers



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum