473,666 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript calculations not transferring to paypal

5 New Member
I am wondering if I may be missing something within my code to lead me to this question. Please forgive me as it has been a while since editing and developing web as I create more web design. I have a client who has created a web site with 1 product and the theory being the more you purchase the bigger the discount. I have created the java code for that but now I am having issue's with the calculations being transmitted to the paypal account. I am not sure where I have missed a step or what I can do to remedy the situation. I'm at my whits end as this has been a struggle.

Here is the code, thanks!!!

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. var divsarray=new Array('div0','div1','div2');
  3.  
  4. function showDivs(divs)
  5. {
  6. //get number of div to show
  7. var num = parseInt(divs);
  8.  
  9. //show the div
  10. document.getElementById(divsarray[num]).style.display='block';
  11.  
  12. //add one for next div
  13. document.getElementById('lastdiv').value=(num+1);
  14.  
  15. //set quantity field
  16. var quantity = 'quantity' + num; 
  17.  
  18. //set price field
  19. var price = 'price' + num;
  20.  
  21. //set total field
  22. var total = 'total' + num;
  23.  
  24. //put values in inputs fields of div displayed above
  25. document.getElementById(quantity).value= document.getElementById('quantity100').value;
  26. document.getElementById(price).value = document.getElementById('price100').value;
  27. document.getElementById(total).value=document.getElementById('total100').value;
  28.  
  29. //Clear the original input fields
  30. document.getElementById('quantity100').value = "";
  31. document.getElementById('mySelect').options[0].selected=true;
  32. document.getElementById('price100').value = "";
  33. document.getElementById('total100').value = "";
  34. document.getElementById('grand').style.display='block';
  35.  
  36. //calculate the grand total
  37. var grand=0;
  38. for(var j=0;j<divsarray.length;j++)
  39. {
  40. var mytotal = "total" + j;
  41. grand = eval(document.getElementById(mytotal).value) + grand;
  42. document.getElementById('grandtotal').value=grand;
  43. }
  44. }
  45.  
  46. function updateForm(what) 
  47. {
  48. selected = what.mySelect.selectedIndex;
  49. values = what.mySelect.options[selected].value;
  50. document.getElementById('price100').value = values;
  51. document.getElementById('total100').value = eval(values * document.getElementById('quantity100').value).toFixed(2);
  52. }
  53. </script>
  54. <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  55.         <input type="hidden" name="cmd" value="_xclick" />
  56.         <input type="hidden" name="upload" value="1" />
  57.         <input type="hidden" name="business" value="jabbett@thingsofskill.com" />
  58.         <input type="hidden" name="currency_code" value="USD" />
  59.         <input type="hidden" name="return" value="http://www.thingsofskill.com/success.html" />
  60.  
  61.         Quantity / Price per Unit / Total
  62.         <div id="div0" style="display:none">
  63.   <input type="text" name="quantity0" id="quantity0">
  64.   <input type="text" name="price0" id="price0">
  65.   <input type="text" name="total0" id="total0" value="0">
  66.   <p>
  67.   </div>
  68.   <div id="div1" style="display:none">
  69.   <input type="text" name="quantity1" id="quantity1">
  70.   <input type="text" name="price1" id="price1">
  71.   <input type="text" name="total1" id="total1" value="0">
  72.   <p>
  73.   </div>
  74.   <div id="div2" style="display:none">
  75.   <input type="text" name="quantity2" id="quantity2">
  76.   <input type="text" name="price2" id="price2">
  77.   <input type="text" name="total2" id="total2" value="0">
  78.   <p>
  79.   </div>
  80.   <div id="grand" style="display:none">
  81.     Order Total:<br>
  82.   <input type="text" value="0" id="grandtotal" name="grandtotal">
  83.   </div>
  84.   <p>
  85.   <input name="quantity100" type="text" id="quantity100" size="3">
  86.   <select name="mySelect" onChange="updateForm(this.form)">
  87.   <option value="">
  88.   <option value="28.00">1
  89.   <option value="24.99">2
  90.   <option value="21.99">3
  91.   </select>
  92.   <input name="price100" type="text" id="price100" size="7">
  93.   <input name="total100" type="text" id="total100" size="7">
  94.    <input type="submit" value="PayPal" />
  95.       </form>
  96.       </td>
  97.     </tr>
  98.   </table>
  99. </div>
Apr 21 '11 #1
0 1194

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2849
by: Tom Cahill | last post by:
The following code will work perfectly on a PC browser, IE or Netscape. However on a Mac browser (IE, Netscape, or Safari) it does not. I have tried it on OSX and OS9. ANy help anyone can offer would be appreciated. Thank you. function calc() { var event1_discount_name = ""; //name of discount to be incorporated into PayPal description var event2_discount_name = "";
3
1156
by: Chris Storey | last post by:
Hi I have some pages which perform Javascript calculations etc. and end up with a number in a box at the bottom of a page. The pages themselves are PHP, but with Javascripts embedded in them. How can I get the results of these calculations (which are in text boxes), and place them into a mysql database?I gather that it may not be possible to do this directly, but is there any way around it? I dont want to have to rewrite the scripts...
2
2127
by: Mark Hannon | last post by:
I am designing a PayPal shopping cart/store for a client and have placed several of PayPal's shopping cart forms on the page to correspond with different products. Each form has a unique name though each of the form's elements have to use PayPal's required naming conventions to pass the data to their server. Many of the forms have hard-coded data in them and these have not caused me any problems. The problems I am having are with 3 forms...
3
1719
by: neutrino | last post by:
Hi, I'v created a site for client, with several pages of products for sale, we're not using any Online payment method yet -so in the meantime, I'v just provided an Order Form, to be completed, printed then mailed off with payment.... what I would really like to do, to improve this greatly - would be to simulate what a paypal "add to cart" button would do - which is click to add an item, and it places that item in a window in a...
3
8032
by: Yourself | last post by:
Hi, I'm trying to post data to PayPal for a shopping cart, basically I want to replicate a form like the following, but create the variables dynamically from code behind: <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="seller@designerfotos.com"> <input type="hidden" name="item_name"
3
20236
by: ykhamitkar | last post by:
Hi I tried the notify_url but it didnt work can you see if I am doing any error. or do i need to change any any setting in paypal site to activate notify_url Here is my html code for the form ================================================ <input type="Hidden" name="cmd" value="_xclick"> <input type="Hidden" name="business" value="username@hotmail.com"> <!-- Allow customer to enter desired quantity --> <input type="Hidden" ...
0
1749
by: Nicodemus | last post by:
Do You Belive? \ cheapbbc@sina.com wrote in news:aecf26b6-4c75-4d87-b09c-a7380875e0f3 @w34g2000prm.googlegroups.com:
1
1870
by: mintu kumar | last post by:
i am trying to make submenu in javascript by the help of section, but he is working?? my code here... {section name=j loop=$menu step=-1} {literal} <script language="JavaScript"> <!-- function mmLoadMenus() { if (window.mm_menu_0419132429_0) return;
12
1859
Avatar19
by: Avatar19 | last post by:
Hi there, I have a class that calls a dynamic countdown on my webpage. when I call the class it looks like this. <script type='text/javascript'> var futuredate=new cdtime("contain","April 21, 2011 12:55:55") futuredate.displaycountdown("days", formatresults) </script>
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7385
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6192
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.