We help IT Professionals succeed at work.

shopping cart CGI call

mmoline asked
Last Modified: 2013-12-25
I am working on a shopping cart app for a clothing company.  I need to let customers indicate size and color of the product they choose.  The products all have SKU's assigned, and I have the CGI call to add the item to the cart.  My question is this:  I was going to use a pull down menu with the size and color choices presented.  I tried using a standard javascript pull down that looked like this:

<form name="formname">
              <select name="selectName" size="1">
                <option value=""> --Select size/color--</option>
                <option value="http://www.myshop.com/olshop/cart.cgi?add=052SW">Small/white</option>

However, this did not work.  It would pull up another window, which I really don't want it to do, and it did not add the item to the cart.    Basically, that is the CGI call above.  I need to add some type of selection system to the pages to let the customer choose size and color.  The built in stuff on this particular shopping cart is not acceptable for the end result I am trying to achieve, but I have to use this cart.  I can do it with images using the following:

<a HREF="http://www.myshop.com/olshop/cart.cgi?add=052SW"><img src="anyimage.gif" width="18" height="20" border="0"></a>

This works just fine, although since it is an HREF, it redirects you to the "view cart" page.  I would like to avoid the redirect, and simply post the selection to the "cart" 'behind the scenes' so to speak without redirecting the shopper.  

The relevant calls are below:

"To use the shopping cart and ordering features of the online shop you don't have to use the default pages - product list, categories and product search. You can directly use some of the CGI's:

/olshop/product.cgi?id=xxxx - this link will display the product with ID xxxx.

/olshop/cart.cgi?add=xxxx - this link will add the product with ID xxxx to the
     shopping cart, and will display the shopping cart contents.

/olshop/cart.cgi - this link will display the shopping cart contents.

/olshop/orderinfo.cgi - this link will proceed to the ordering form.

For example, if you want customers to add the product 1234 to their shopping cart by clicking on the product picture somewhere on your web site you can use the following HTML code:

     <A HREF="/olshop/cart.cgi?add=1234"><IMG SRC="product.gif"><A>

I don't profess to know what the heck I am doing with this type of setup, so any help/ other suggestions would be appreciated, thank you in advance!!!
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)

you can use javascript code to achieve what you want.

"....I was going to use a pull down menu with the size and color choices presented......"

this is totally fine. But what i dont understand is why you dont want to submit the form using CGI, either as a POST method or via GET method??

using CGI with any of the above methods you can easily get what you want!!


<form method=GET action="/cgi-bin/my_script.cgi">

<select name="add" size="1">
  <option value=""> --Select size/color--</option>
  <option value="052SW">Small/white</option>
  <option value="060XB">XL/black</option>

<input type=img src="some_image.gif">

Now if the user were to click on the image your request would be sent to the CGI script.

However if you dont want a CGI script to be invoked for each and every user action, you might want to consider using cookies with javascript.

i have some websites that offer FREE PERL code for shopping carts. (PERL since i develop using it :) )

they will give you a very good working example, WITH the source code!!



Thank you Manesh....I know it was a simple one, I promise to challenge you more in the future!!

Glad to have helped you.

looking forward to more challenging ones :-)

Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.