Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding multiple items in shopping cart w/ one click

    Hello, I am currently building a shopping cart and I have a small problem.

    On the product page, I have the option that if a customer would like to add extra "products", then they would click on the desired checkboxes to add what they would want and then when they click on the "finish purchase" link, they would be directed to the cart page with their selection or selections shown.

    I build the following javascript to give the link the right value based on the selected checkboxes:
    Code:
    function checkTheChecks(product_id) {
    
    	var firstBox = document.forms[0].elements[0]
    	var secondBox = document.forms[0].elements[1]
    	var thirdBox = document.forms[1].elements[0]
    
    	if (firstBox.checked && secondBox.checked) {
    	location.href = "errorpage.html"
    	}
    		else if (firstBox.checked) {
    		location.href = "cart.php?WHAT SHOULD I PUT HERE" + product_id
    		}
    		else if (secondBox.checked) {
    		location.href = "cart.php?id2=3" +  product_id
    		}
    		else if (firstBox.checked && thirdBox.checked) {
    		location.href = "cart.php?id2=5&id3=7" +  product_id
    		}
    		else if (secondBox.checked && thirdBox.checked) {
    		location.href = "cart.php?" +  product_id
    		}
    		else if (thirdBox.checked) {
    		location.href = "cart.php?" +  product_id
    		}
    			else {
    			location.href = "cart.php" +  product_id
    			}
    	}
    Making multiple ids didn't work out for me, but i placed it with the code so that you could see what i've tried.

    I am a beginner on PHP and MySQL, I already set the database but the problem is the way of handling multiple items in a single session variable.
    Excuse me if i am a bit vague, but I will repeat myself, i am a beginner at PHP.
    Any help is greatly appreciated.

    Here is the link to the target site that I am working on:
    http://www.printingcarousel.com/busi...ds_afirst.html
    Last edited by nervegas87; 06-29-2007 at 11:19 PM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •