login  Naam:   Wachtwoord: 
Registreer je!
 Forum

invoervelden - andere werkt (bij mij) niet

Offline brinkman_m - 04/08/2007 22:16
Avatar van brinkman_mNieuw lid Ik voer deze nogmaals door omdat ik het andere bericht dat ik zojuist geplaatst heb niet kan benaderen.

Beste,

Ik heb een webwinkel script van het internet gedownload. Het toevoegen, verwijderen en aanpassen van artikelen gaat heel makkelijk met Dreamweaver. Maar ik zou dit graag via een webpagina willen doen zodat ik het op iedere pc met internet kan doen.

Het systeempje bevat in feite maar 5 bestanden (2 JavaScript en 3 HTML).

Mijn vraag is of iemand weet hoe je een webpagina kan maken met daarop invoervelden zodat je de producten kan toevoegen.

De huidige pagina's zijn:

CategorieA.HTML
  1. <title>CategorieA.html</title>
  2. <script type="text/javascript" src="language-nl.js"></script>
  3. <script type="text/javascript" src="nopcart.js"></script>
  4. </head>
  5.  
  6. Op deze pagina bevinden zich alle producten van categorie A.<br><br><br>
  7.  
  8.  
  9. Beschrijving Categorie A Product 1
  10.  
  11. <!--Shopping Cart Begin-->
  12. <form name="order" action="mandje.html" onSubmit="AddToCart(this);">
  13. Aantal:
  14. <input type="text" size="2" name="QUANTITY" onChange="this.value=CKquantity(this.value)" value="1">
  15. <input type="image" src="images/bestel.gif" border=0 value="Add to Cart" align="top">
  16. <input type="hidden" name="PRICE" value="10.00">
  17. <input type="hidden" name="NAME" value="Categorie A Product 1">
  18. <input type="hidden" name="ID_NUM" value="CATAPROD1">
  19. <input type="hidden" name="SHIPPING" value="2.50">
  20. </form>
  21. <!--Shopping Cart Einde -->
  22.  
  23.  
  24. Beschrijving Categorie A Product 2
  25.  
  26. <!--Shopping Cart Begin-->
  27. <form name="order" action="mandje.html" onSubmit="AddToCart(this);">
  28. Aantal:
  29. <input type="text" size="2" name="QUANTITY" onChange="this.value=CKquantity(this.value)" value="1">
  30. <input type="image" src="images/bestel.gif" border=0 value="Add to Cart" align="top">
  31. <input type="hidden" name="PRICE" value="20.00">
  32. <input type="hidden" name="NAME" value="Categorie A Product 2">
  33. <input type="hidden" name="ID_NUM" value="CATAPROD2">
  34. <input type="hidden" name="SHIPPING" value="3.50">
  35. </form>
  36. <!--Shopping Cart Einde -->
  37.  
  38. </body>
  39. </html>


Mandje.HTML
  1. <title>mandje.html</title>
  2. <script type="text/javascript" src="language-nl.js"></script>
  3. <script type="text/javascript" src="nopcart.js"></script>
  4. </head>
  5.  
  6. Dit zit momenteel in jouw mandje:<br>
  7.  
  8. <form action="bestelformulier.html" name="form" method="get" onsubmit="return ValidateCart(this)">
  9. <script type="text/javascript">ManageCart();</script>
  10. <input type="image" src="images/bestelformulier.gif" border="0" alt="naar bestelformulier">
  11. </form>
  12.  
  13. <a href="beginpagina.html"><img src="images/verderwinkelen.gif" alt="verder winkelen" border="0"></a>
  14.  
  15. </body>
  16. </html>


language-nl.js
  1. strSorry = "Sorry, Uw winkelwagen is vol, gaat u aub naar de Kassa !!!";
  2. strAdded = " aan uw winkelwagen toegevoegd.";
  3. strRemove = "Klik op 'Ok' om dit product uit uw winkelwagen te verwijderen.";
  4. strILabel = "Bestelcode";
  5. strQLabel = "Aantal";
  6. strDLabel = "Product Omschrijving";
  7. strPLabel = "Prijs";
  8. strSLabel = "Verzendkosten";
  9. strRLabel = "Verwijder";
  10. strRButton= "Verwijder";
  11. strSUB = "SUBTOTAAL";
  12. strSHIP = "VERZENDKOSTEN";
  13. strTAX = "BTW";
  14. strTOT = "TOTAAL";
  15. strErrQty = "Ongeldig Aantal.";
  16. strNewQty = 'Voer een nieuw aantal in aub:';
  17.  
  18. Language = 'nl';
  19. bLanguageDefined = true;



nopcart.js
  1. //=====================================================================||
  2. // NOP Design JavaScript Shopping Cart ||
  3. // ||
  4. // For more information on SmartSystems, or how NOPDesign can help you ||
  5. // Please visit us on the WWW at http://www.nopdesign.com ||
  6. // ||
  7. // Javascript portions of this shopping cart software are available as ||
  8. // freeware from NOP Design. You must keep this comment unchanged in ||
  9. // your code. For more information contact FreeCart@NopDesign.com. ||
  10. // ||
  11. // JavaScript Shop Module, V.4.4.0 ||
  12. //=====================================================================||
  13.  
  14. //---------------------------------------------------------------------||
  15. // Global Options ||
  16. // ---------------- ||
  17. // Shopping Cart Options, you can modify these options to change the ||
  18. // the way the cart functions. ||
  19. // ||
  20. // Language Packs ||
  21. // ============== ||
  22. // You may include any language pack before nopcart.js in your HTML ||
  23. // pages to change the language. Simply include a language pack with ||
  24. // a script src BEFORE the <SCRIPT SRC="nopcart.js">... line. ||
  25. // For example: <SCRIPT SRC="language-en.js"></SCRIPT> ||
  26. // ||
  27. // Options For Everyone: ||
  28. // ===================== ||
  29. // * MonetarySymbol: string, the symbol which represents dollars/euro, ||
  30. // in your locale. ||
  31. // * DisplayNotice: true/false, controls whether the user is provided ||
  32. // with a popup letting them know their product is added to the cart ||
  33. // * DisplayShippingColumn: true/false, controls whether the managecart||
  34. // and checkout pages display shipping cost column. ||
  35. // * DisplayShippingRow: true/false, controls whether the managecart ||
  36. // and checkout pages display shipping cost total row. ||
  37. // * DisplayTaxRow: true/false, controls whether the managecart ||
  38. // and checkout pages display tax cost total row. ||
  39. // * TaxRate: number, your area's current tax rate, ie: if your tax ||
  40. // rate was 7.5%, you would set TaxRate = 0.075 ||
  41. // * TaxByRegion: true/false, when set to true, the user is prompted ||
  42. // with TaxablePrompt to determine if they should be charged tax. ||
  43. // In the USA, this is useful to charge tax to those people who live ||
  44. // in a particular state, but no one else. ||
  45. // * TaxPrompt: string, popup message if user has not selected either ||
  46. // taxable or nontaxable when TaxByRegion is set to true. ||
  47. // * TaxablePrompt: string, the message the user is prompted with to ||
  48. // select if they are taxable. If TaxByRegion is set to false, this ||
  49. // has no effect. Example: 'Arizona Residents' ||
  50. // * NonTaxablePrompt: string, same as above, but the choice for non- ||
  51. // taxable people. Example: 'Other States' ||
  52. // * MinimumOrder: number, the minium dollar amount that must be ||
  53. // purchased before a user is allowed to checkout. Set to 0.00 ||
  54. // to disable. ||
  55. // * MinimumOrderPrompt: string, Message to prompt users with when ||
  56. // they have not met the minimum order amount. ||
  57. // ||
  58. // Payment Processor Options: ||
  59. // ========================== ||
  60. // * PaymentProcessor: string, the two digit payment processor code ||
  61. // for support payment processor gateways. Setting this field to ||
  62. // anything other than an empty string will override your OutputItem ||
  63. // settings -- so please be careful when receiving any form data. ||
  64. // Support payment processor gateways are: ||
  65. // * Authorize.net (an) ||
  66. // * Worldpay (wp) ||
  67. // * LinkPoint (lp)
  68. // ||
  69. // Options For Programmers: ||
  70. // ======================== ||
  71. // * OutputItem<..>: string, the name of the pair value passed at ||
  72. // checkouttime. Change these only if you are connecting to a CGI ||
  73. // script and need other field names, or are using a secure service ||
  74. // that requires specific field names. ||
  75. // * AppendItemNumToOutput: true/false, if set to true, the number of ||
  76. // each ordered item will be appended to the output string. For ||
  77. // example if OutputItemId is 'ID_' and this is set to true, the ||
  78. // output field name will be 'ID_1', 'ID_2' ... for each item. ||
  79. // * HiddenFieldsToCheckout: true/false, if set to true, hidden fields ||
  80. // for the cart items will be passed TO the checkout page, from the ||
  81. // ManageCart page. This is set to true for CGI/PHP/Script based ||
  82. // checkout pages, but should be left false if you are using an ||
  83. // HTML/Javascript Checkout Page. Hidden fields will ALWAYS be ||
  84. // passed FROM the checkout page to the Checkout CGI/PHP/ASP/Script ||
  85. //---------------------------------------------------------------------||
  86.  
  87. //Options for Everyone:
  88. MonetarySymbol = '&#8364;&nbsp;'; // euro
  89. DisplayNotice = true;
  90. DisplayShippingColumn = true;
  91. DisplayShippingRow = true;
  92. DisplayTaxRow = true;
  93. TaxRate = 0.21; // 21% BTW
  94. TaxByRegion = false;
  95. TaxPrompt = 'For tax purposes, please select if you are an Arizona resident before continuing';
  96. TaxablePrompt = 'Arizona Residents';
  97. NonTaxablePrompt = 'Other States';
  98. MinimumOrder = 0.00;
  99. MinimumOrderPrompt = 'Jouw bestelling is beneden de minimale bestelwaarde.';
  100.  
  101. //Payment Processor Options:
  102. PaymentProcessor = '';
  103.  
  104. //Options for Programmers:
  105. OutputItemId = 'ID_';
  106. OutputItemQuantity = 'QUANTITY_';
  107. OutputItemPrice = 'PRICE_';
  108. OutputItemName = 'NAME_';
  109. OutputItemShipping = 'SHIPPING_';
  110. OutputItemAddtlInfo = 'ADDTLINFO_';
  111. OutputOrderSubtotal = 'SUBTOTAL';
  112. OutputOrderShipping = 'SHIPPING';
  113. OutputOrderTax = 'TAX';
  114. OutputOrderTotal = 'TOTAL';
  115. AppendItemNumToOutput = true;
  116. HiddenFieldsToCheckout = false;
  117.  
  118.  
  119. //=====================================================================||
  120. //---------------------------------------------------------------------||
  121. // YOU DO NOT NEED TO MAKE ANY MODIFICATIONS BELOW THIS LINE ||
  122. //---------------------------------------------------------------------||
  123. //=====================================================================||
  124.  
  125.  
  126. //---------------------------------------------------------------------||
  127. // Language Strings ||
  128. // ------------------ ||
  129. // These strings will not be used unless you have not included a ||
  130. // language pack already. You should NOT modify these, but instead ||
  131. // modify the strings in language-**.js where ** is the language pack ||
  132. // you are using. ||
  133. //---------------------------------------------------------------------||
  134. if ( !bLanguageDefined ) {
  135. strSorry = "I'm Sorry, your cart is full, please proceed to checkout.";
  136. strAdded = " added to your shopping cart.";
  137. strRemove = "Click 'Ok' to remove this product from your shopping cart.";
  138. strILabel = "Product Id";
  139. strDLabel = "Product Name/Description";
  140. strQLabel = "Quantity";
  141. strPLabel = "Price";
  142. strSLabel = "Shipping";
  143. strRLabel = "Remove From Cart";
  144. strRButton= "Remove";
  145. strSUB = "SUBTOTAL";
  146. strSHIP = "SHIPPING";
  147. strTAX = "TAX";
  148. strTOT = "TOTAL";
  149. strErrQty = "Invalid Quantity.";
  150. strNewQty = 'Please enter new quantity:';
  151. bLanguageDefined = true;
  152. }
  153.  
  154.  
  155. //---------------------------------------------------------------------||
  156. // FUNCTION: CKquantity ||
  157. // PARAMETERS: Quantity to ||
  158. // RETURNS: Quantity as a number, and possible alert ||
  159. // PURPOSE: Make sure quantity is represented as a number ||
  160. //---------------------------------------------------------------------||
  161. function CKquantity(checkString) {
  162. var strNewQuantity = "";
  163.  
  164. for ( i = 0; i < checkString.length; i++ ) {
  165. ch = checkString.substring(i, i+1);
  166. if ( (ch >= "0" && ch <= "9") || (ch == '.') )
  167. strNewQuantity += ch;
  168. }
  169.  
  170. if ( strNewQuantity.length < 1 )
  171. strNewQuantity = "1";
  172.  
  173. return(strNewQuantity);
  174. }
  175.  
  176.  
  177. //---------------------------------------------------------------------||
  178. // FUNCTION: AddToCart ||
  179. // PARAMETERS: Form Object ||
  180. // RETURNS: Cookie to user's browser, with prompt ||
  181. // PURPOSE: Adds a product to the user's shopping cart ||
  182. //---------------------------------------------------------------------||
  183. function AddToCart(thisForm) {
  184. var iNumberOrdered = 0;
  185. var bAlreadyInCart = false;
  186. var notice = "";
  187. iNumberOrdered = GetCookie("NumberOrdered");
  188.  
  189. if ( iNumberOrdered == null )
  190. iNumberOrdered = 0;
  191.  
  192. if ( thisForm.ID_NUM == null )
  193. strID_NUM = "";
  194. else
  195. strID_NUM = thisForm.ID_NUM.value;
  196.  
  197. if ( thisForm.QUANTITY == null )
  198. strQUANTITY = "1";
  199. else
  200. strQUANTITY = thisForm.QUANTITY.value;
  201.  
  202. if ( thisForm.PRICE == null )
  203. strPRICE = "0.00";
  204. else
  205. strPRICE = thisForm.PRICE.value;
  206.  
  207. if ( thisForm.NAME == null )
  208. strNAME = "";
  209. else
  210. strNAME = thisForm.NAME.value;
  211.  
  212. if ( thisForm.SHIPPING == null )
  213. strSHIPPING = "0.00";
  214. else
  215. strSHIPPING = thisForm.SHIPPING.value;
  216.  
  217. if ( thisForm.ADDITIONALINFO == null ) {
  218. strADDTLINFO = "";
  219. } else {
  220. strADDTLINFO = thisForm.ADDITIONALINFO[thisForm.ADDITIONALINFO.selectedIndex].value;
  221. }
  222. if ( thisForm.ADDITIONALINFO2 != null ) {
  223. strADDTLINFO += "; " + thisForm.ADDITIONALINFO2[thisForm.ADDITIONALINFO2.selectedIndex].value;
  224. }
  225. if ( thisForm.ADDITIONALINFO3 != null ) {
  226. strADDTLINFO += "; " + thisForm.ADDITIONALINFO3[thisForm.ADDITIONALINFO3.selectedIndex].value;
  227. }
  228. if ( thisForm.ADDITIONALINFO4 != null ) {
  229. strADDTLINFO += "; " + thisForm.ADDITIONALINFO4[thisForm.ADDITIONALINFO4.selectedIndex].value;
  230. }
  231.  
  232. //Is this product already in the cart? If so, increment quantity instead of adding another.
  233. for ( i = 1; i <= iNumberOrdered; i++ ) {
  234. NewOrder = "Order." + i;
  235. database = "";
  236. database = GetCookie(NewOrder);
  237.  
  238. Token0 = database.indexOf("|", 0);
  239. Token1 = database.indexOf("|", Token0+1);
  240. Token2 = database.indexOf("|", Token1+1);
  241. Token3 = database.indexOf("|", Token2+1);
  242. Token4 = database.indexOf("|", Token3+1);
  243.  
  244. fields = new Array;
  245. fields[0] = database.substring( 0, Token0 );
  246. fields[1] = database.substring( Token0+1, Token1 );
  247. fields[2] = database.substring( Token1+1, Token2 );
  248. fields[3] = database.substring( Token2+1, Token3 );
  249. fields[4] = database.substring( Token3+1, Token4 );
  250. fields[5] = database.substring( Token4+1, database.length );
  251.  
  252. if ( fields[0] == strID_NUM &&
  253. fields[2] == strPRICE &&
  254. fields[3] == strNAME &&
  255. fields[5] == strADDTLINFO
  256. ) {
  257. bAlreadyInCart = true;
  258. dbUpdatedOrder = strID_NUM + "|" +
  259. (parseInt(strQUANTITY)+parseInt(fields[1])) + "|" +
  260. strPRICE + "|" +
  261. strNAME + "|" +
  262. strSHIPPING + "|" +
  263. strADDTLINFO;
  264. strNewOrder = "Order." + i;
  265. DeleteCookie(strNewOrder, "/");
  266. SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
  267. notice = strQUANTITY + " " + strNAME + strAdded;
  268. break;
  269. }
  270. }
  271.  
  272.  
  273. if ( !bAlreadyInCart ) {
  274. iNumberOrdered++;
  275.  
  276. if ( iNumberOrdered > 12 )
  277. alert( strSorry );
  278. else {
  279. dbUpdatedOrder = strID_NUM + "|" +
  280. strQUANTITY + "|" +
  281. strPRICE + "|" +
  282. strNAME + "|" +
  283. strSHIPPING + "|" +
  284. strADDTLINFO;
  285.  
  286. strNewOrder = "Order." + iNumberOrdered;
  287. SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
  288. SetCookie("NumberOrdered", iNumberOrdered, null, "/");
  289. notice = strQUANTITY + " " + strNAME + strAdded;
  290. }
  291. }
  292.  
  293. if ( DisplayNotice )
  294. alert(notice);
  295. }
  296.  
  297.  
  298. //---------------------------------------------------------------------||
  299. // FUNCTION: getCookieVal ||
  300. // PARAMETERS: offset ||
  301. // RETURNS: URL unescaped Cookie Value ||
  302. // PURPOSE: Get a specific value from a cookie ||
  303. //---------------------------------------------------------------------||
  304. function getCookieVal (offset) {
  305. var endstr = document.cookie.indexOf (";", offset);
  306.  
  307. if ( endstr == -1 )
  308. endstr = document.cookie.length;
  309. return(unescape(document.cookie.substring(offset, endstr)));
  310. }
  311.  
  312.  
  313. //---------------------------------------------------------------------||
  314. // FUNCTION: FixCookieDate ||
  315. // PARAMETERS: date ||
  316. // RETURNS: date ||
  317. // PURPOSE: Fixes cookie date, stores back in date ||
  318. //---------------------------------------------------------------------||
  319. function FixCookieDate (date) {
  320. var base = new Date(0);
  321. var skew = base.getTime();
  322.  
  323. date.setTime (date.getTime() - skew);
  324. }
  325.  
  326.  
  327. //---------------------------------------------------------------------||
  328. // FUNCTION: GetCookie ||
  329. // PARAMETERS: Name ||
  330. // RETURNS: Value in Cookie ||
  331. // PURPOSE: Retrieves cookie from users browser ||
  332. //---------------------------------------------------------------------||
  333. function GetCookie (name) {
  334. var arg = name + "=";
  335. var alen = arg.length;
  336. var clen = document.cookie.length;
  337. var i = 0;
  338.  
  339. while ( i < clen ) {
  340. var j = i + alen;
  341. if ( document.cookie.substring(i, j) == arg ) return(getCookieVal (j));
  342. i = document.cookie.indexOf(" ", i) + 1;
  343. if ( i == 0 ) break;
  344. }
  345.  
  346. return(null);
  347. }
  348.  
  349.  
  350. //---------------------------------------------------------------------||
  351. // FUNCTION: SetCookie ||
  352. // PARAMETERS: name, value, expiration date, path, domain, security ||
  353. // RETURNS: Null ||
  354. // PURPOSE: Stores a cookie in the users browser ||
  355. //---------------------------------------------------------------------||
  356. function SetCookie (name,value,expires,path,domain,secure) {
  357. document.cookie = name + "=" + escape (value) +
  358. ((expires) ? "; expires=" + expires.toGMTString() : "") +
  359. ((path) ? "; path=" + path : "") +
  360. ((domain) ? "; domain=" + domain : "") +
  361. ((secure) ? "; secure" : "");
  362. }
  363.  
  364.  
  365. //---------------------------------------------------------------------||
  366. // FUNCTION: DeleteCookie ||
  367. // PARAMETERS: Cookie name, path, domain ||
  368. // RETURNS: null ||
  369. // PURPOSE: Removes a cookie from users browser. ||
  370. //---------------------------------------------------------------------||
  371. function DeleteCookie (name,path,domain) {
  372. if ( GetCookie(name) ) {
  373. document.cookie = name + "=" +
  374. ((path) ? "; path=" + path : "") +
  375. ((domain) ? "; domain=" + domain : "") +
  376. "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  377. }
  378. }
  379.  
  380.  
  381. //---------------------------------------------------------------------||
  382. // FUNCTION: MoneyFormat ||
  383. // PARAMETERS: Number to be formatted ||
  384. // RETURNS: Formatted Number ||
  385. // PURPOSE: Reformats Dollar Amount to #.## format ||
  386. //---------------------------------------------------------------------||
  387. function moneyFormat(input) {
  388. var dollars = Math.floor(input);
  389. var tmp = new String(input);
  390.  
  391. for ( var decimalAt = 0; decimalAt < tmp.length; decimalAt++ ) {
  392. if ( tmp.charAt(decimalAt)=="." )
  393. break;
  394. }
  395.  
  396. var cents = "" + Math.round(input * 100);
  397. cents = cents.substring(cents.length-2, cents.length)
  398. dollars += ((tmp.charAt(decimalAt+2)=="9")&&(cents=="00"))? 1 : 0;
  399.  
  400. if ( cents == "0" )
  401. cents = "00";
  402.  
  403. return(dollars + "." + cents);
  404. }
  405.  
  406.  
  407. //---------------------------------------------------------------------||
  408. // FUNCTION: RemoveFromCart ||
  409. // PARAMETERS: Order Number to Remove ||
  410. // RETURNS: Null ||
  411. // PURPOSE: Removes an item from a users shopping cart ||
  412. //---------------------------------------------------------------------||
  413. function RemoveFromCart(RemOrder) {
  414. if ( confirm( strRemove ) ) {
  415. NumberOrdered = GetCookie("NumberOrdered");
  416. for ( i=RemOrder; i < NumberOrdered; i++ ) {
  417. NewOrder1 = "Order." + (i+1);
  418. NewOrder2 = "Order." + (i);
  419. database = GetCookie(NewOrder1);
  420. SetCookie (NewOrder2, database, null, "/");
  421. }
  422. NewOrder = "Order." + NumberOrdered;
  423. SetCookie ("NumberOrdered", NumberOrdered-1, null, "/");
  424. DeleteCookie(NewOrder, "/");
  425. location.href=location.href;
  426. }
  427. }
  428.  
  429.  
  430. //---------------------------------------------------------------------||
  431. // FUNCTION: ChangeQuantity ||
  432. // PARAMETERS: Order Number to Change Quantity ||
  433. // RETURNS: Null ||
  434. // PURPOSE: Changes quantity of an item in the shopping cart ||
  435. //---------------------------------------------------------------------||
  436. function ChangeQuantity(OrderItem,NewQuantity) {
  437. if ( isNaN(NewQuantity) ) {
  438. alert( strErrQty );
  439. } else {
  440. NewOrder = "Order." + OrderItem;
  441. database = "";
  442. database = GetCookie(NewOrder);
  443.  
  444. Token0 = database.indexOf("|", 0);
  445. Token1 = database.indexOf("|", Token0+1);
  446. Token2 = database.indexOf("|", Token1+1);
  447. Token3 = database.indexOf("|", Token2+1);
  448. Token4 = database.indexOf("|", Token3+1);
  449.  
  450. fields = new Array;
  451. fields[0] = database.substring( 0, Token0 );
  452. fields[1] = database.substring( Token0+1, Token1 );
  453. fields[2] = database.substring( Token1+1, Token2 );
  454. fields[3] = database.substring( Token2+1, Token3 );
  455. fields[4] = database.substring( Token3+1, Token4 );
  456. fields[5] = database.substring( Token4+1, database.length );
  457.  
  458. dbUpdatedOrder = fields[0] + "|" +
  459. NewQuantity + "|" +
  460. fields[2] + "|" +
  461. fields[3] + "|" +
  462. fields[4] + "|" +
  463. fields[5];
  464. strNewOrder = "Order." + OrderItem;
  465. DeleteCookie(strNewOrder, "/");
  466. SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
  467. location.href=location.href;
  468. }
  469. }
  470.  
  471.  
  472. //---------------------------------------------------------------------||
  473. // FUNCTION: GetFromCart ||
  474. // PARAMETERS: Null ||
  475. // RETURNS: Product Table Written to Document ||
  476. // PURPOSE: Draws current cart product table on HTML page ||
  477. // **DEPRECATED FUNCTION, USE ManageCart or Checkout** ||
  478. //---------------------------------------------------------------------||
  479. function GetFromCart( fShipping ) {
  480. ManageCart( );
  481. }
  482.  
  483.  
  484. //---------------------------------------------------------------------||
  485. // FUNCTION: RadioChecked ||
  486. // PARAMETERS: Radio button to check ||
  487. // RETURNS: True if a radio has been checked ||
  488. // PURPOSE: Form fillin validation ||
  489. //---------------------------------------------------------------------||
  490. function RadioChecked( radiobutton ) {
  491. var bChecked = false;
  492. var rlen = radiobutton.length;
  493. for ( i=0; i < rlen; i++ ) {
  494. if ( radiobutton[i].checked )
  495. bChecked = true;
  496. }
  497. return bChecked;
  498. }
  499.  
  500.  
  501. //---------------------------------------------------------------------||
  502. // FUNCTION: QueryString ||
  503. // PARAMETERS: Key to read ||
  504. // RETURNS: value of key ||
  505. // PURPOSE: Read data passed in via GET mode ||
  506. //---------------------------------------------------------------------||
  507. QueryString.keys = new Array();
  508. QueryString.values = new Array();
  509. function QueryString(key) {
  510. var value = null;
  511. for (var i=0;i<QueryString.keys.length;i++) {
  512. if (QueryString.keys[i]==key) {
  513. value = QueryString.values[i];
  514. break;
  515. }
  516. }
  517. return value;
  518. }
  519.  
  520. //---------------------------------------------------------------------||
  521. // FUNCTION: QueryString_Parse ||
  522. // PARAMETERS: (URL string) ||
  523. // RETURNS: null ||
  524. // PURPOSE: Parses query string data, must be called before Q.S. ||
  525. //---------------------------------------------------------------------||
  526. function QueryString_Parse() {
  527. var query = window.location.search.substring(1);
  528. var pairs = query.split("&"); for (var i=0;i<pairs.length;i++) {
  529. var pos = pairs[i].indexOf('=');
  530. if (pos >= 0) {
  531. var argname = pairs[i].substring(0,pos);
  532. var value = pairs[i].substring(pos+1);
  533. QueryString.keys[QueryString.keys.length] = argname;
  534. QueryString.values[QueryString.values.length] = value;
  535. }
  536. }
  537. }
  538.  
  539.  
  540. //---------------------------------------------------------------------||
  541. // FUNCTION: ManageCart ||
  542. // PARAMETERS: Null ||
  543. // RETURNS: Product Table Written to Document ||
  544. // PURPOSE: Draws current cart product table on HTML page ||
  545. //---------------------------------------------------------------------||
  546. function ManageCart( ) {
  547. var iNumberOrdered = 0; //Number of products ordered
  548. var fTotal = 0; //Total cost of order
  549. var fTax = 0; //Tax amount
  550. var fShipping = 0; //Shipping amount
  551. var strTotal = ""; //Total cost formatted as money
  552. var strTax = ""; //Total tax formatted as money
  553. var strShipping = ""; //Total shipping formatted as money
  554. var strOutput = ""; //String to be written to page
  555. var bDisplay = true; //Whether to write string to the page (here for programmers)
  556.  
  557. iNumberOrdered = GetCookie("NumberOrdered");
  558. if ( iNumberOrdered == null )
  559. iNumberOrdered = 0;
  560.  
  561. if ( bDisplay )
  562. strOutput = "<TABLE CLASS=\"nopcart\"><TR>" +
  563. "<TD CLASS=\"nopheader\"><B>"+strILabel+"</B></TD>" +
  564. "<TD CLASS=\"nopheader\"><B>"+strDLabel+"</B></TD>" +
  565. "<TD CLASS=\"nopheader\"><B>"+strQLabel+"</B></TD>" +
  566. "<TD CLASS=\"nopheader\"><B>"+strPLabel+"</B></TD>" +
  567. (DisplayShippingColumn?"<TD CLASS=\"nopheader\"><B>"+strSLabel+"</B></TD>":"") +
  568. "<TD CLASS=\"nopheader\"><B>"+strRLabel+"</B></TD></TR>";
  569.  
  570. if ( iNumberOrdered == 0 ) {
  571. strOutput += "<TR><TD COLSPAN=6 CLASS=\"nopentry\"><CENTER><BR><B>Jouw mandje is leeg.</B><BR><BR></CENTER></TD></TR>";
  572. }
  573.  
  574. for ( i = 1; i <= iNumberOrdered; i++ ) {
  575. NewOrder = "Order." + i;
  576. database = "";
  577. database = GetCookie(NewOrder);
  578.  
  579. Token0 = database.indexOf("|", 0);
  580. Token1 = database.indexOf("|", Token0+1);
  581. Token2 = database.indexOf("|", Token1+1);
  582. Token3 = database.indexOf("|", Token2+1);
  583. Token4 = database.indexOf("|", Token3+1);
  584.  
  585. fields = new Array;
  586. fields[0] = database.substring( 0, Token0 ); // Product ID
  587. fields[1] = database.substring( Token0+1, Token1 ); // Quantity
  588. fields[2] = database.substring( Token1+1, Token2 ); // Price
  589. fields[3] = database.substring( Token2+1, Token3 ); // Product Name/Description
  590. fields[4] = database.substring( Token3+1, Token4 ); // Shipping Cost
  591. fields[5] = database.substring( Token4+1, database.length ); //Additional Information
  592.  
  593. fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
  594. fShipping += (parseInt(fields[1]) * parseFloat(fields[4]) );
  595. fTax = (fTotal * TaxRate);
  596. strTotal = moneyFormat(fTotal);
  597. strTax = moneyFormat(fTax);
  598. strShipping = moneyFormat(fShipping);
  599.  
  600. if ( bDisplay ) {
  601. strOutput += "<TR><TD CLASS=\"nopentry\">" + fields[0] + "</TD>";
  602.  
  603. if ( fields[5] == "" )
  604. strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + "</TD>";
  605. else
  606. strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + " - <I>"+ fields[5] + "</I></TD>";
  607.  
  608. strOutput += "<TD CLASS=\"nopentry\"><INPUT TYPE=TEXT NAME=Q SIZE=2 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
  609. strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[2]) + "</TD>";
  610.  
  611. if ( DisplayShippingColumn ) {
  612. if ( parseFloat(fields[4]) > 0 )
  613. strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[4]) + "</TD>";
  614. else
  615. strOutput += "<TD CLASS=\"nopentry\">N/A</TD>";
  616. }
  617.  
  618. strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER><input type=button value=\" "+strRButton+" \" onClick=\"RemoveFromCart("+i+")\" class=\"nopbutton\"></TD></TR>";
  619. }
  620.  
  621. if ( AppendItemNumToOutput ) {
  622. strFooter = i;
  623. } else {
  624. strFooter = "";
  625. }
  626. if ( HiddenFieldsToCheckout ) {
  627. strOutput += "<input type=hidden name=\"" + OutputItemId + strFooter + "\" value=\"" + fields[0] + "\">";
  628. strOutput += "<input type=hidden name=\"" + OutputItemQuantity + strFooter + "\" value=\"" + fields[1] + "\">";
  629. strOutput += "<input type=hidden name=\"" + OutputItemPrice + strFooter + "\" value=\"" + fields[2] + "\">";
  630. strOutput += "<input type=hidden name=\"" + OutputItemName + strFooter + "\" value=\"" + fields[3] + "\">";
  631. strOutput += "<input type=hidden name=\"" + OutputItemShipping + strFooter + "\" value=\"" + fields[4] + "\">";
  632. strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">";
  633. }
  634.  
  635. }
  636.  
  637. if ( bDisplay ) {
  638. strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strSUB+"</B></TD>";
  639. strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B>" + MonetarySymbol + strTotal + "</B></TD>";
  640. strOutput += "</TR>";
  641.  
  642. if ( DisplayShippingRow ) {
  643. strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strSHIP+"</B></TD>";
  644. strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B>" + MonetarySymbol + strShipping + "</B></TD>";
  645. strOutput += "</TR>";
  646. }
  647.  
  648. if ( DisplayTaxRow || TaxByRegion ) {
  649. if ( TaxByRegion ) {
  650. strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strTAX+"</B></TD>";
  651. strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B>";
  652. strOutput += "<input type=radio name=\""+OutputOrderTax+"\" value=\"" + strTax + "\">";
  653. strOutput += TaxablePrompt + ": " + MonetarySymbol + strTax;
  654. strOutput += "<BR><input type=radio name=\""+OutputOrderTax+"\" value=\"0.00\">";
  655. strOutput += NonTaxablePrompt + ": " + MonetarySymbol + "0.00";
  656. strOutput += "</B></TD>";
  657. strOutput += "</TR>";
  658. } else {
  659. strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strTAX+"</B></TD>";
  660. strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B>" + MonetarySymbol + strTax + "</B></TD>";
  661. strOutput += "</TR>";
  662. }
  663. }
  664.  
  665. if ( !TaxByRegion ) {
  666. strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strTOT+"</B></TD>";
  667. strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</B></TD>";
  668. strOutput += "</TR>";
  669. }
  670. strOutput += "</TABLE>";
  671.  
  672. if ( HiddenFieldsToCheckout ) {
  673. strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strTotal + "\">";
  674. strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + strShipping + "\">";
  675. strOutput += "<input type=hidden name=\""+OutputOrderTax+"\" value=\""+ MonetarySymbol + strTax + "\">";
  676. strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\" value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
  677. }
  678. }
  679. g_TotalCost = (fTotal + fShipping + fTax);
  680.  
  681. document.write(strOutput);
  682. document.close();
  683. }
  684.  
  685. //---------------------------------------------------------------------||
  686. // FUNCTION: ValidateCart ||
  687. // PARAMETERS: Form to validate ||
  688. // RETURNS: true/false ||
  689. // PURPOSE: Validates the managecart form ||
  690. //---------------------------------------------------------------------||
  691. var g_TotalCost = 0;
  692. function ValidateCart( theForm ) {
  693. if ( TaxByRegion ) {
  694. if ( !RadioChecked(eval("theForm."+OutputOrderTax)) ) {
  695. alert( TaxPrompt );
  696. return false;
  697. }
  698. }
  699.  
  700. if ( MinimumOrder >= 0.01 ) {
  701. if ( g_TotalCost < MinimumOrder ) {
  702. alert( MinimumOrderPrompt );
  703. return false;
  704. }
  705. }
  706.  
  707. return true;
  708. }
  709.  
  710. //---------------------------------------------------------------------||
  711. // FUNCTION: CheckoutCart ||
  712. // PARAMETERS: Null ||
  713. // RETURNS: Product Table Written to Document ||
  714. // PURPOSE: Draws current cart product table on HTML page for ||
  715. // checkout. ||
  716. //---------------------------------------------------------------------||
  717. function CheckoutCart( ) {
  718. var iNumberOrdered = 0; //Number of products ordered
  719. var fTotal = 0; //Total cost of order
  720. var fTax = 0; //Tax amount
  721. var fShipping = 0; //Shipping amount
  722. var strTotal = ""; //Total cost formatted as money
  723. var strTax = ""; //Total tax formatted as money
  724. var strShipping = ""; //Total shipping formatted as money
  725. var strOutput = ""; //String to be written to page
  726. var bDisplay = true; //Whether to write string to the page (here for programmers)
  727. var strPP = ""; //Payment Processor Description Field
  728.  
  729. iNumberOrdered = GetCookie("NumberOrdered");
  730. if ( iNumberOrdered == null )
  731. iNumberOrdered = 0;
  732.  
  733. if ( TaxByRegion ) {
  734. QueryString_Parse();
  735. fTax = parseFloat( QueryString( OutputOrderTax ) );
  736. strTax = moneyFormat(fTax);
  737. }
  738.  
  739. if ( bDisplay )
  740. strOutput = "<TABLE CLASS=\"nopcart\"><TR>" +
  741. "<TD CLASS=\"nopheader\"><B>"+strILabel+"</B></TD>" +
  742. "<TD CLASS=\"nopheader\"><B>"+strDLabel+"</B></TD>" +
  743. "<TD CLASS=\"nopheader\"><B>"+strQLabel+"</B></TD>" +
  744. "<TD CLASS=\"nopheader\"><B>"+strPLabel+"</B></TD>" +
  745. (DisplayShippingColumn?"<TD CLASS=\"nopheader\"><B>"+strSLabel+"</B></TD>":"") +
  746. "</TR>";
  747.  
  748. for ( i = 1; i <= iNumberOrdered; i++ ) {
  749. NewOrder = "Order." + i;
  750. database = "";
  751. database = GetCookie(NewOrder);
  752.  
  753. Token0 = database.indexOf("|", 0);
  754. Token1 = database.indexOf("|", Token0+1);
  755. Token2 = database.indexOf("|", Token1+1);
  756. Token3 = database.indexOf("|", Token2+1);
  757. Token4 = database.indexOf("|", Token3+1);
  758.  
  759. fields = new Array;
  760. fields[0] = database.substring( 0, Token0 ); // Product ID
  761. fields[1] = database.substring( Token0+1, Token1 ); // Quantity
  762. fields[2] = database.substring( Token1+1, Token2 ); // Price
  763. fields[3] = database.substring( Token2+1, Token3 ); // Product Name/Description
  764. fields[4] = database.substring( Token3+1, Token4 ); // Shipping Cost
  765. fields[5] = database.substring( Token4+1, database.length ); //Additional Information
  766.  
  767. fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
  768. fShipping += (parseInt(fields[1]) * parseFloat(fields[4]) );
  769. if ( !TaxByRegion ) fTax = (fTotal * TaxRate);
  770. strTotal = moneyFormat(fTotal);
  771. if ( !TaxByRegion ) strTax = moneyFormat(fTax);
  772. strShipping = moneyFormat(fShipping);
  773.  
  774. if ( bDisplay ) {
  775. strOutput += "<TR><TD CLASS=\"nopentry\">" + fields[0] + "</TD>";
  776.  
  777. if ( fields[5] == "" )
  778. strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + "</TD>";
  779. else
  780. strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + " - <I>"+ fields[5] + "</I></TD>";
  781.  
  782. strOutput += "<TD CLASS=\"nopentry\">" + fields[1] + "</TD>";
  783. strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[2]) + "</TD>";
  784.  
  785. if ( DisplayShippingColumn ) {
  786. if ( parseFloat(fields[4]) > 0 )
  787. strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[4]) + "</TD>";
  788. else
  789. strOutput += "<TD CLASS=\"nopentry\">N/A</TD>";
  790. }
  791.  
  792. strOutput += "</TR>";
  793. }
  794.  
  795. if ( AppendItemNumToOutput ) {
  796. strFooter = i;
  797. } else {
  798. strFooter = "";
  799. }
  800. if ( PaymentProcessor != '' ) {
  801. //Process description field for payment processors instead of hidden values.
  802. //Format Description of product as:
  803. // ID, Name, Qty X
  804. strPP += fields[0] + ", " + fields[3];
  805. if ( fields[5] != "" )
  806. strPP += " - " + fields[5];
  807. strPP += ", Qty. " + fields[1] + "\n";
  808. } else {
  809. strOutput += "<input type=hidden name=\"" + OutputItemId + strFooter + "\" value=\"" + fields[0] + "\">";
  810. strOutput += "<input type=hidden name=\"" + OutputItemQuantity + strFooter + "\" value=\"" + fields[1] + "\">";
  811. strOutput += "<input type=hidden name=\"" + OutputItemPrice + strFooter + "\" value=\"" + fields[2] + "\">";
  812. strOutput += "<input type=hidden name=\"" + OutputItemName + strFooter + "\" value=\"" + fields[3] + "\">";
  813. strOutput += "<input type=hidden name=\"" + OutputItemShipping + strFooter + "\" value=\"" + fields[4] + "\">";
  814. strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">";
  815. }
  816.  
  817. }
  818.  
  819. if ( bDisplay ) {
  820. strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strSUB+"</B></TD>";
  821. strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strTotal + "</B></TD>";
  822. strOutput += "</TR>";
  823.  
  824. if ( DisplayShippingRow ) {
  825. strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strSHIP+"</B></TD>";
  826. strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strShipping + "</B></TD>";
  827. strOutput += "</TR>";
  828. }
  829.  
  830. if ( DisplayTaxRow || TaxByRegion ) {
  831. strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strTAX+"</B></TD>";
  832. strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strTax + "</B></TD>";
  833. strOutput += "</TR>";
  834. }
  835.  
  836. strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strTOT+"</B></TD>";
  837. strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</B></TD>";
  838. strOutput += "</TR>";
  839.  
  840. strOutput += "</TABLE>";
  841.  
  842.  
  843. if ( PaymentProcessor == 'an') {
  844. //Process this for Authorize.net WebConnect
  845. strOutput += "<input type=hidden name=\"x_Version\" value=\"3.0\">";
  846. strOutput += "<input type=hidden name=\"x_Show_Form\" value=\"PAYMENT_FORM\">";
  847. strOutput += "<input type=hidden name=\"x_Description\" value=\""+ strPP + "\">";
  848. strOutput += "<input type=hidden name=\"x_Amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
  849. } else if ( PaymentProcessor == 'wp') {
  850. //Process this for WorldPay
  851. strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
  852. strOutput += "<input type=hidden name=\"amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
  853. } else if ( PaymentProcessor == 'lp') {
  854. //Process this for LinkPoint
  855. strOutput += "<input type=hidden name=\"mode\" value=\"fullpay\">";
  856. strOutput += "<input type=hidden name=\"chargetotal\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
  857. strOutput += "<input type=hidden name=\"tax\" value=\""+ MonetarySymbol + strTax + "\">";
  858. strOutput += "<input type=hidden name=\"subtotal\" value=\""+ MonetarySymbol + strTotal + "\">";
  859. strOutput += "<input type=hidden name=\"shipping\" value=\""+ MonetarySymbol + strShipping + "\">";
  860. strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
  861. } else {
  862. strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strTotal + "\">";
  863. strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + strShipping + "\">";
  864. strOutput += "<input type=hidden name=\""+OutputOrderTax+"\" value=\""+ MonetarySymbol + strTax + "\">";
  865. strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\" value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
  866. }
  867. }
  868.  
  869. document.write(strOutput);
  870. document.close();
  871. }
  872.  
  873. //=====================================================================||
  874. // END NOP Design SmartPost Shopping Cart ||
  875. //=====================================================================||



Kortom: Het moet een pagina zijn waarmee je artikelen kunt toevoegen, verwijderen en aanpassen.

Ik zelf zie het voor me als een pagina met diverse invoer velden, heb alleen geen idee hoe dit technisch zit.

Hopelijk wilt iemand zich daarover buigen.

0 antwoorden

Gesponsorde links
Er zijn nog geen reacties op dit bericht.
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.231s