Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to add a Shopping Cart to an HTML page having a table of Manuscripts. The price of Manuscripts changes according to Country. Hence, I could not understand how I add the function of add to cart to this table?

<body id="page-top" class="index">

    <table style="width:100%">
        <style>
            table,
            th,
            td {
                border: 1px solid black;
                border-collapse: collapse;
            }

            th,
            td {
                padding: 2px;
            }
        </style>

        </tr>
        <table>
            <tbody>
                <thead>
                    <tr>
                        <tr>
                            <th>Code</th>
                            <th>Name of Manuscript </th>
                            <th>No. of Pages and Size</th>
                            <th>Select your Country Name</th>
                            <th>Price</th>
                            <th>Order It</th>
                        </tr>
                </thead>

                <!-- 1st row -->
                <tr>
                    <td>1-1</td>
                    <td>Alankarchintamani /Author Charukirti Pandit अलङ्कारचिन्तामणि: /ले. चारुकीर्ति पंडित:</td>
                    <td>P.315 C (21x16)</td>

                    <td>
                        <select id="mySelect" onchange="myFunction()">
                            <hide>
                                <option value="">Select Country</hide>
                            <option value="Rs. 2,520">India
                                <option value="$ 315">Outside India
                    </td>

                    </select>

                    <td id="demo">
                        <script>
                            function myFunction() {
                                var x = document.getElementById("mySelect").value;
                                document.getElementById("demo").innerHTML = x;
                            }
                        </script>
                    </td>

                    <td>
                        <input type="submit" value="Order It">
                    </td>
                </tr>


What I have tried:

I could not understand how to add "add to cart" function to the following code:

<td>
<select id="mySelect" onchange="myFunction()">
<hide><option value="">Select Country</hide> 
<option value="Rs. 2,520">India
<option value="$ 315">Outside India
</td>


Pl. guide me to add this item to the shopping cart.

Thanks in advance.
Posted
Updated 11-Jun-19 21:34pm
Comments
ZurdoDev 11-Jun-19 8:23am    
There are a million ways to do shopping carts. You can either build your own or find some downloads to include in your code.

1 solution

See this overview of shopping cart plugins: jQuery Shopping Cart Plugins | jQuery Script[^]
 
Share this answer
 
Comments
Sudeshna2 12-Jun-19 9:47am    
Thanks for your solution!
I have selected a template from the link you have given above.
From that I have a following difficulty:

I have onchange function to select price country wise.



Select Country
India
Outside India



function myFunction() {
var x = document.getElementById("mySelect").value;
document.getElementById("demo").innerHTML = x;
}


In the template to add price only numbers are accepted, but I have to give id value i.e. #demo to get amount country wise in add to cart button.

Code of 'add to cart' button:

Add to Cart

In the above code if I give a number after "price": it is excepted, but I have to give #demo

Pl. guide me how I make changes in the above code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900