1 Replies - 518 Views - Last Post: 02 August 2014 - 05:04 AM

#1 jamesmarkham94  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 25-March 14

need help with creating shopping basket

Posted 01 August 2014 - 04:33 PM

I am trying to create a shopping basket and so far I have got my list of items that are for sale on one page and on my second page i have the shopping basket. when i click the button to add to bssket on the selling page, the item displays where it should do within the shopping basket page. the problem is when i add a second item to the basket it does not display as having 2 items added, rather it gets rid of the first item and displays only the second. i need to get multiple items to add to the basket. i have barely no knowledge on javascript so am clueless on how to fix this can anybody give me advice or tell me what code i need to fix this please?


<!DOCTYPE HTML>
<html>
<head>
    <title>motoractive.co.uk/buy-a-car</title>
    <link rel="stylesheet" type="text/css" href="../stylesheet.css" />
</head>
<body>
    <header class="Banner">
		<IMG SRC= "../images/logo.jpg" />		
        </header>
    <nav>
            
            <UL CLASS="nav">
                <LI><A HREF="../FIRSTWEBPAGE.html">Home page</A></LI>
                <LI><A HREF="">Sell a car </A></LI>
                <LI><A HREF="pages/research-compare.html">Research and compare</A></LI>
                <LI><A HREF="">Reviews</A></LI>
		<LI><A HREF="">Insurance quotes</A></LI>
            </UL>
            
        </nav>
    <br>
    <br>
    <br>
    <br>
    <div class="section_one_border">
        <h3 class="headings">
            Vauxhall Corsa 1.4i 16V Design 3dr</h3>
        <img src="../images/selling/selling_page_images/vaux_corsa.jpg" />
        <p>
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
        </p>
        <h3 class="headings">
            Price: £1000</h3>
        <ul class="buy_bar">
            <li><a href="">Reviews</a></li>
            <li><a href="">Insurance quotes</a></li>
            <li><a href="shopping_basket.html?car=Vauxhall Corsa 1.4i 16V Design 3dr&price=£1000&qty=1">
                Add to basket</a></li>
            <li><a href="">Quick preview</a></li>
        </ul>
    </div>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <div class="section_one_border">
        <h3 class="headings">
            Audi A1 1.4 TFSI S Line 3dr</h3>
        <img src="../images/selling/selling_page_images/audi_a1.jpg" />
        <p>
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
        </p>
	<h3 class="headings">
            Price: £1000</h3>
        <ul class="buy_bar">
            <li><a href="">Reviews</a></li>
            <li><a href="">Insurance quotes</a></li>
            <li><a href="shopping_basket.html?car=Audi A1 1.4 TFSI S Line 3dr&price=£1000&qty=1">Add to
                basket</a></li>
            <li><a href="">Quick preview</a></li>
        </ul>
    </div>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <div class="section_one_border">
        <h3 class="headings">
            car name here</h3>
        <img src="../images/selling/vaux_corsa_1.4i.jpg" />
        <p>
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
            text-here-text-here-text-here-text-here-text-here-text-here- text-here-text-here-text-here-text-here-text-here-text-here-
        </p>
        <h3 class="headings">
            Price: £1000</h3>
        <ul class="buy_bar">
            <li><a href="">Reviews</a></li>
            <li><a href="">Insurance quotes</a></li>
            <li><a href="shopping_basket.html?car=car name here&price=£1000&qty=1">Add to basket</a></li>
            <li><a href="">Quick preview</a></li>
        </ul>
    </div>
</html>





 <script language="javascript">
        function getParams() {
            var idx = document.URL.indexOf('?');
            var params = {};
            if (idx != -1) {
                var pairs = document.URL.substring(idx + 1, document.URL.length).split('&');
                for (var i = 0; i < pairs.length; i++) {
                    nameVal = pairs[i].split('=');
                    params[nameVal[0]] = nameVal[1];
                }
            }
            return params;
        }

        params = getParams();
        carname = unescape(params["car"]);
        price = unescape(params["price"]);
        quantity = unescape(params["qty"]);
    </script>
    <table border="1px" style="height: 76px; width: 922px">
        <th>
            Product
        </th>
        <th>
            Price
        </th>
        <th>
            Quantity
        </th>
        <tr>
            <td>
                <script language="javascript">                    document.write(carname);</script>
            </td>
            <td>
                <script language="javascript">                    document.write(price);</script>
            </td>
            <td>
                <script language="javascript">                    document.write(quantity);</script>
            </td>
        </tr>
    </table>
    <a href="">Check Out</a>



This post has been edited by jamesmarkham94: 01 August 2014 - 04:36 PM


Is This A Good Question/Topic? 0
  • +

Replies To: need help with creating shopping basket

#2 Blindman67  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 134
  • View blog
  • Posts: 592
  • Joined: 15-March 14

Re: need help with creating shopping basket

Posted 02 August 2014 - 05:04 AM

You will need to use some server side scripting with this. It is not a simple job as you will need session tracking, user authentication. You will need DB tables for users products, orders, etc. Payment will need a secure connection, you will have to use SQL transactions to make sure you do not stuff up orders. This is not a job for someone that has very little programming experience.

I would strongly suggest you use an existing system and modify it to suit your needs. I believe WordPress has many solutions, but its been a very long time since I have done that type of site so maybe someone that has used an off the shelf shopping system can make some suggestions for you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1