473,498 Members | 1,704 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hopefully easy programming question

I'm new to this (2 days new) so please bear with me.
I want have a form & button working with a paypal order so that when
the user puts in the order quantity on my page, the javascript selects
the correct price based on quantity and sends those 2 numbers to
paypal.

I have no idea how to do this. I don't know if it should go in the
ShowPRice function or if it should be done in a form. Would someone
help me?

What I have written so far:

<html>
<head>
<script language="javascript" type="text/javascript">
<!--
function CalculatePrice(NumOrdered)
{
if (NumOrdered>=6 && NumOrdered<=10)
{var ItemPrice = 5.00 }
else if (NumOrdered >=11 && NumOrdered<=25)
{var ItemPrice = 4.50 }
else if (NumOrdered >=26 && NumOrdered<=80)
{var ItemPrice = 4.00 }
else if (NumOrdered> 80)
{var ItemPrice = 3.50 }
else if (NumOrdered< 6)
{alert("Minimum wholesale order is 6") ;
var ItemPrice = 5.00 }
else
{alert("You did not enter a number!");
var ItemPrice = 5.00}
return ItemPrice ;
}

function ShowPrice(NumOrdered)
{
var FinalPrice=CalculatePrice(NumOrdered);
alert("Price per unit: "+FinalPrice)
}

// -->
</script>
</head>

<body>

<***** now this form fm2a works very nicely and shows me the correct
<***** price
<form name="fm2a">
Enter quantity :
<input type="text" name="quantity">
<input type="button" name="dis" value="Add to Cart"
onClick='ShowPrice(document.fm2a.quantity.value)'>
</form>
<***** But what I really want is the button to do place a paypal
order,
<***** inserting the quantity ordered and the correct price. What
I've
<***** done here does not work.
<form name="submit" target="paypal"
action="https://www.paypal.com/cgi-bin/webscr" method="post">
Enter quantity :
<input type="text" name="quantity">
<input type="button" name="dis" value="Add to Cart"
onClick='ShowPrice(document.submit.quantity.value) '>
<input type="hidden" name="add" value=NumOrdered>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="pa****@mystore.com">
<input type="hidden" name="item_name" value="Wholesale item">
<input type="hidden" name="item_number" value="WRTH">
<input type="hidden" name="amount" value=FinalPrice>
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
</form>
</body>
</html>
Jul 23 '05 #1
7 1016
On 26 May 2004 17:43:45 -0700, Andrea Chen wrote:
I want have a form & button working with a paypal order


AFAIR, you do that at the PayPal end by setting up
different links to go to. You could then choose which
link with JS, or simply list the different products as
separate links..

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #2
Andrew Thompson <Se********@www.invalid> wrote in message news:<1s*****************************@40tude.net>. ..
On 26 May 2004 17:43:45 -0700, Andrea Chen wrote:
I want have a form & button working with a paypal order


AFAIR, you do that at the PayPal end by setting up
different links to go to. You could then choose which
link with JS, or simply list the different products as
separate links..


They're not different products, just different quantities of the same
product. I think I need to have a Paypal store to do that (which I
don't...). I'll look into it, though.
Jul 23 '05 #3

"Andrea Chen" <di********@hotmail.com> wrote in message
news:b9**************************@posting.google.c om...
Andrew Thompson <Se********@www.invalid> wrote in message

news:<1s*****************************@40tude.net>. ..
On 26 May 2004 17:43:45 -0700, Andrea Chen wrote:
I want have a form & button working with a paypal order


AFAIR, you do that at the PayPal end by setting up
different links to go to. You could then choose which
link with JS, or simply list the different products as
separate links..


They're not different products, just different quantities of the same
product. I think I need to have a Paypal store to do that (which I
don't...). I'll look into it, though.


You don't have to do anything of the sort. When the user clicks on the link,
the PayPal shopping cart page appears andyour customer can change the
*uantity field*there.

go to www.charlescrumesoftware.com/dms.htm and click on one of the "Add to
Cart" buttons to see this.

HTH.

Charles...

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.691 / Virus Database: 452 - Release Date: 5/26/04
Jul 23 '05 #4
Lee
Andrea Chen said:

I'm new to this (2 days new) so please bear with me.
I want have a form & button working with a paypal order so that when
the user puts in the order quantity on my page, the javascript selects
the correct price based on quantity and sends those 2 numbers to
paypal.

I have no idea how to do this. I don't know if it should go in the
ShowPRice function or if it should be done in a form. Would someone
help me?
I don't know much about PayPal. Maybe I'm wrong, but
unless you know that I'm wrong, you should reconsider
using client-side Javascript to compute your prices and
send the result off to be billed. There are a lot of us
out here who can read your code and make changes to it on
the fly so that the function sends PayPal whatever price
we happen to feel like paying.

Even if you're not actually committed to sell at the price
that PayPal receives, I'll bet that it's going to cost you
time and trouble (at least) to back out of the transaction.
Now that you know that you shouldn't do this, here's how:
<input type="hidden" name="amount" value=FinalPrice>


Apparently you were hoping that this line would set the
value of FinalPrice at the time of form submission. Since
that's an HTML line, it actually sets the value at the time
that the form is first displayed, and since HTML doesn't
know anything about variables, it sets the value to "FinalPrice".

The correct way to have your function set the value of the
hidden form field named "amount" is:

function ShowPrice(NumOrdered)
{
var FinalPrice=CalculatePrice(NumOrdered);
document.forms["submit"].elements["amount"].value=FinalPrice;
}

Note that this doesn't submit the form for you.

Jul 23 '05 #5
"Charles Crume" <cc@charlescrumesoftware.com> wrote in message news:<gA*************@fe1.columbus.rr.com>...
You don't have to do anything of the sort. When the user clicks on the link,
the PayPal shopping cart page appears andyour customer can change the
*uantity field*there.


Ummm....Charles... I think you may have missed the point behind my
dipping into javascript. The *price* *changes* according to the
quantity ordered.

-andrea-
Jul 23 '05 #6
Lee <RE**************@cox.net> wrote in message news:<c9*********@drn.newsguy.com>...
I don't know much about PayPal. Maybe I'm wrong, but
unless you know that I'm wrong, you should reconsider
using client-side Javascript to compute your prices and
send the result off to be billed. There are a lot of us
out here who can read your code and make changes to it on
the fly so that the function sends PayPal whatever price
we happen to feel like paying.
I have in fact tried it just to see if it could be done, and it can.
Copy the page source, tweak it and run it. Doesn't matter html or
javascript, if the prices are in the page source, anyone can mess with
it.
The correct way to have your function set the value of the
hidden form field named "amount" is:

function ShowPrice(NumOrdered)
{
var FinalPrice=CalculatePrice(NumOrdered);
document.forms["submit"].elements["amount"].value=FinalPrice;
}

Note that this doesn't submit the form for you.


I see. Thank you very much. I think though as you and Andrew said,
it's probably safer to have the prices locked somewhere else.

-andrea-
Jul 23 '05 #7
Andrea Chen wrote:
Lee [...] wrote [...]
I don't know much about PayPal. Maybe I'm wrong, but
unless you know that I'm wrong, you should reconsider
using client-side Javascript to compute your prices and
send the result off to be billed. There are a lot of us
out here who can read your code and make changes to it on
the fly so that the function sends PayPal whatever price
we happen to feel like paying.


I have in fact tried it just to see if it could be done, and it can.
Copy the page source, tweak it and run it. Doesn't matter html or
javascript, if the prices are in the page source, anyone can mess with
it.


It is much more simple. Consider something like

javascript:alert(document.forms[0].elements['foo'].value = 0.0042);

typed in the Location Bar ;-)
PointedEars
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2201
by: rdsteph | last post by:
I am having a lot of fun using the pyGoogle module ( http://pygoogle.sourceforge.net/ ) that uses the Google API. It is about as easy to use as I can imagine, and it is a lot nicer than using my...
6
1606
by: max | last post by:
Hi, I'm verry new to cpp ( I think im using only C but n e way ) in my prog I need a user to input a choice with cin >> myvar. Actually mymar is type char but when I type something higher than 1...
3
3080
by: Gwen Morse | last post by:
I'd like to alternate the rows in a table between having a shaded background and being transparent to the background. It's a table of people's names, phone numbers, and beeper numbers. So, by...
2
1205
by: Bonj | last post by:
I have got the starting bits of a game that I am trying to write. I did start to write it in VC++6, but found the basic windows GDI to be of general poor performance for animation. So I decided to...
13
1499
by: tindog | last post by:
I am brand new to this programming especially C#. I am confused (at the moment). I have bought two books to get started to learn C# language and Visual C#.net 2003 in 24 hours. Which is the best to...
4
945
by: Brian Henry | last post by:
I have a listbox, and i need to show a text string for selection, but each item is tied to a number (not visible) i need to select the visible text and have it return the number value, i know its...
1
1063
by: Brad Allison | last post by:
Okay, I am grabbing data from a dinosaur, an AS400 system. One of the date fields is formated as decimal so the data adapter is filling the data set with these decimal numbers (ie 712004 for today...
7
2430
by: SteveM | last post by:
I am sure this is an easy question, but being relatively new to ASP.NET programming, I can not quite grasp what I need to accomplish what I need to do. What I have is a word document that is...
3
1863
by: Gus Gassmann | last post by:
Hi all: I've been working with XML schemas for about a year now, strictly monkey-see-monkey-do so far. (For instance, I did not know about namespaces until yesterday.) My access to the internet...
3
1507
by: miya | last post by:
On Apr 26, 4:36 pm, bvidinli <bvidi...@gmail.comwrote: Django is the way to go for web development. http://www.djangoproject.com/ cya -- Nicolás Miyasato ( miya )
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
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...
0
7379
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...
0
5462
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,...
0
3093
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...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
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 ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.