Click to See Complete Forum and Search --> : Form problem using Paypal


jtatooine
08-26-2003, 11:16 AM
Hi, I am using forms to purchase items on my webpage through Paypal. I want to have a drop down menu with some options, but the options will have to change the price of the item.

Paypal says on their web page that their option menu's won't change the price, but I know there has to be a way to do it.

Can anybody give me any ideas. I can give you links to my page if you'll need to see it.

Thanks.

Fang
08-26-2003, 05:46 PM
Add the link is ...

jtatooine
08-26-2003, 06:37 PM
http://www.gradwellhouse.com/buttonshy/stickerformtest.htm

there's the link. basically the drop down menu tells you the changes I would like them to make, but they obviously don't change anything yet.

Fang
08-27-2003, 02:54 AM
Check out the changes:

function ChangePrice(str) {
var normal=1;
if(str!="Normal") {
var str=str.split("$");
str=str[1].split(" ");
normal+=parseInt(str[0]);
}
document.getElementById('cost').innerHTML="$"+normal;
}


<p>Sticker - Costs <span id="cost">$1.00</span></p>
<form name="itemlist" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="jtatooine@aol.com">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="item_name" value="Custom Sticker">
<input type="hidden" name="amount" value="1.00">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<table>
<tr>
<td>
<input type="hidden" name="on0" value="Type">Type
</td>
<td>
<select name="os0" onchange="ChangePrice(this.options[this.selectedIndex].value);">
<option value="Normal">Normal
<option value="Glossy ($1 more)">Glossy ($1 more)
<option value="Reflective ($2 more)">Reflective ($2 more)
<option value="Glow in the Dark($3 more)">Glow in the Dark($3 more)
</select>
</td>
</tr>
</table>
<input type="image" src="x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" width="68" height="23">
</form>

jtatooine
08-27-2003, 07:14 AM
hey Fang, Thanks so much. I tried it and the amount at the top does change, but when I get to the paypal page it is still charging $1.00 for each item. check it out.

http://www.gradwellhouse.com/buttonshy/stickerformtest.htm

Fang
08-27-2003, 07:58 AM
I expected you to have to do some more work on the form.
Item name, quantity etc. Add this as the last line in function ChangePrice

document.itemlist.amount.value=normal;

jtatooine
08-27-2003, 08:10 AM
yup, now it works. thanks for the tips. I really only know simple html but I'm getting there. These forums are a big help.

jtatooine
08-27-2003, 08:55 AM
another question, where should I start if I were going to alter the price in a different way? Say was $2.00 for a regular sticker. $4.00 for a glossy. $5.00 for reflective, and $10.00 for a glow in the dark one.

Is it a simple change or a whole new script?

Fang
08-27-2003, 01:02 PM
The normal cost is changed in the function ChangePrice() the line var normal=1;
The others are changed in the options where ever you see a "$" sign.
If the prices are in dollars and cents ($2.50) then the script would need to be changed.
Change some of the prices and see whan happens.

jtatooine
09-06-2003, 06:56 AM
so I did all this and now everything is working great and of course I have an all new question. Say I want more than one of this form on the page, I tried to copy and paste the code more than once on the page and it gave me an error?

Fang
09-06-2003, 09:23 AM
you can add as many as you like by giving a few tag attributes a different index (colored red)
I do not know if this method would work for paypal.

<script type="text/javascript">
<!--
function ChangePrice(str, num) {
var normal=1;
if(str!="Normal") {
var str=str.split("$");
str=str[1].split(" ");
normal+=parseInt(str[0]);
}
document.getElementById('cost'+num).innerHTML="$"+normal;
}
//-->
</script>

</head>
<body>
Sticker - Costs <span id="cost1">$1.00</span></p>
<form name="itemlist1" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="jtatooine@aol.com">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="item_name" value="Custom Sticker">
<input type="hidden" name="amount" value="1.00">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<table>
<tr>
<td>
<input type="hidden" name="on1" value="Type">Type
</td>
<td>
<select name="os1" onchange="ChangePrice (this.options[this.selectedIndex].value, 1);">
<option value="Normal">Normal
<option value="Glossy ($1 more)">Glossy ($1 more)
<option value="Reflective ($2 more)">Reflective ($2 more)
<option value="Glow in the Dark($3 more)">Glow in the Dark($3 more)
</select>
</td>
</tr>
</table>
<input type="image" src="x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" width="68" height="23">
</form>
Badge - Costs <span id="cost2">$1.00</span></p>
<form name="itemlist2" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="jtatooine@aol.com">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="item_name" value="Custom Sticker">
<input type="hidden" name="amount" value="1.00">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<table>
<tr>
<td>
<input type="hidden" name="on0" value="Type">Type
</td>
<td>
<select name="os0" onchange="ChangePrice (this.options[this.selectedIndex].value, 2);">
<option value="Normal">Normal
<option value="Glossy ($1 more)">Glossy ($1 more)
<option value="Reflective ($2 more)">Reflective ($2 more)
<option value="Glow in the Dark($3 more)">Glow in the Dark($3 more)
</select>
</td>
</tr>
</table>
<input type="image" src="x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" width="68" height="23">
</form>
</body>

brendandonhue
09-06-2003, 10:27 AM
I would highly reccommend doing this kind of think serverside, or 13% or users will be paying $1 for all of your items because they don't have javascript.

jtatooine
09-06-2003, 04:06 PM
What exactly is serverside?

brendandonhue
09-06-2003, 05:04 PM
A language that runs on the server, such as Perl, CGI, ASP, etc.