View Full Version : Cookies and forms

mag wa
02-01-2005, 11:54 PM
I need to use Cookies with order forms

I need to use the cookies to do like a checkout page, after the user has chosen certain products, each product had an order button to add it if the user wants it, so if the user add the item to their shopping cart , using the cookies I would like to hold the item within an array then store the array indexes rather than detailed item information in the cookie.
Then I would like to display the itmes on a separate line within a table along with the default quantity, price and total then a sub-total and grand total... an update button to update the quantity, it is nearly like Amazon website....I am a beginner in JS and this is a bit complicated for me specially the use of cookies and arrays.
Many thanks :thumbsup:

02-02-2005, 12:12 AM
Okay although it probably possible to do what you've asked, it'd would cause a lot of problems, and there's no guarentee that it'll work for every user that visits your site and the code will be on the large size.

My suggestion would be to learn PHP or ASP or some other server-side language and build a shopping system using these languages and a database. I can't promise that the code will be shorter, but it's more likely to work and you don't have to rely on the user having JS enabled and cookies enabled.

JS is okay for doing simple little tasks, but for a shopping system it's not going to be powerful enough.

Sorry I can't be of more help. If you want to know more about cookies and arrays, search this forum for previous posts, there'll be plenty of previous questions answered to help you understand cookies and arrays.

mag wa
02-02-2005, 12:20 AM
I need to do it in Javascript , this is my assignement....

02-02-2005, 02:15 AM
I need to do it in Javascript , this is my assignement....Then shouldn't you be figuring this out yourself?

mag wa
02-02-2005, 12:47 PM
It is a long assignement and I am stuck with the cookies bit, I cannot move from there, I need help with that bit....(online course, have no tutor...)

mag wa
02-03-2005, 07:51 PM
Any ideas, I am trying to do it, but no use...
here is a code that I have done, but don't know how to make an array for different files, I mean every product has got a different file, how to make an array to hold cookies from different files..
here is one of the files



<IMG SRC="King.jpg" Border=0>

<font face="default">

<b><font face="verdana, arial, helvetica" color="#CC6600">
Track Listings</font></b></font>
<b>Disc: 1</b><br>
<table width=100% cellpadding=3 cellspacing=0 border=0>
<tr valign=top><td width=50%>
1. O Come, O Come, Emmanuel!<br>
2. Once In Royal Davidís City<br>3. Angels, From The Realms Of Glory<br>
4. Adam Lay Ybounden<br>5. O Little Town Of Bethlehem<br>6. In Dulci Jubilo<br>
7. The First Nowell<br>8. I Saw Three Ships<br>9. God Rest You Merry, Gentlemen<br>
10. Quem Pastores Laudavere<br>11. Personent Hodie<br>12. The Holly And The Ivy<br>
13. A Spotless Rose<br>

</td><td width=50%>
14. Away In A Manger<br>
15. While Shepherds Watched<br>
16. Tomorrow Shall Be My Dancing Day<br>
17. Up! Good Christian Folk And Listen<br>
18. In The Bleak Midwinter<br>19. Ding Dong! Merrily On High<br>
20. Silent Night<br>21. The Three Kings<br>22. The Lamb [Tavener]<br>
23. Sussex Carol<br>24. O Come, All Ye Faithful<br>
25. Hark! The Herald Angels Sing<br>
<b>Disc: 2</b><br>

<table width=100% cellpadding=3 cellspacing=0 border=0>
<tr valign=top><td width=50%>
1. Miserere-Allegri [Abridged]<br>
2. Vespers-Monteverdi<br>
3. Jesu, Joy Of Manís Desiring-Bach<br>
4. Ave Verum Corpus-Mozart<br>5. Magnificat-Bach<br>
6. Dear Lord And Father Of Mankind-Parry<br>7. Chichester Psalms-Bernstein<br>
8. I Was A Lad-Parry<br>9. Jubilate Deo-Britten<br>10. Thou Knowest Lord-Purcell<br>
11. Ave Verum Corpus-Byrd<br>
</td><td width=50%>
12. Vespers-Rachmaninov<br>13. Requiem-Durufle<br>14. Requiem-Rutter<br>15. Requiem-Faure<br>16. Beati Quorum Via-Stanford<br>17. Totus Tuus-Gorecki [Abridged]<br>18. Salvator Mundi-Tallis<br>19. Zadok The Priest-Handel<br>20. Five Mystical Songs-Vaughan Williams<br>21. Messiah-Handel<br>22. Gloria-Vivaldi<br>


function SetCookie(){
var WantToBuy=prompt("Do you want to Add this product into your shopping cart,yes or no");
if (BuyKingCD=="yes")
<FORM NAME="myForm">
<INPUT TYPE="button" Value="Order Now" onClick="SetCookie()">



Please help, I am in a mess!!!!!