Frag Infinity Tournament, Inc. - FITES LAN Party - www.fites.net
LAN Party Forums => Support Group => Started by: Czar on August 25, 2008, 08:07:33 AM
-
Here's the dizzle. I'm trying to add a PayPal shopping cart to my chainmaille website. I've done this before, years ago, for a different side business but this time, I need to modify some code so the buyer can specify more options.
<input name="item_number" type="radio" value="15 dice">
When the above radio button is checked, it changes the Item Number variable to "15 dice"
At the same time, I would also like the code to update the cost of a 15 dice capacity dice bag
<input type="hidden" name="amount" value="10.00">
..How can I get TWO variables to be updated at once using only the one radio button? There are other radio buttons used, each with different dice capacities and each has an associated `amount` value. For example, a 30 count bag would be $20.
Suggestions?
-
Wouldn't the item look more like:
<input name="15_dice" type="radio" value="10.00">
That way you just have to select the number of them you want?
Also, if you want to setup WordPress there is a shopping module addon that is free and can process paypal.
-
Yes. but paypal's shopping cart won't process it using the "15_dice" name as its not one of the fields the paypal button jobbie looks for to process.. The item number will show the buyer what size bag they are ordering. The `amount` variable tells paypal how much to charge.
Here is the prototype page I designed with the required fields.
(http://www.czaralex.com/images/ppfront.png)
And the way it looks on the PayPal cart. Note the Price for a 30 count bag is $20, not $10. That's the
other field I need to change along with the Item#
(http://www.czaralex.com/images/ppcart.png)
Hmm.. wordpress eh? I've set that up before, so I know its not a pain, but I'm not sure how to turn it in to something that isn't wordpress looking. Know what I mean? (and I need this done by Wed night)
-
http://www.zabsart.com/
Still not done, but that is like 1 hour of work.
As for the javascript. Let me see what I can do when I get home from the office.
-
I don't believe there is a way to update 2 variables with one radio button. I think the way to get the feature you want is to do a bit of back end processing when you submit the form and adjust the price based on the size they select.
-
I hit some a javascript chan on IRC and someone suggested I catch the input before its sent to paypal and add the extra value. here's what I came up with:
<SCRIPT FOR="cmdsubmit" EVENT="onclick" LANGUAGE="JavaScript">
<!--
var TheForm;
TheForm = document.orderform;
if (TheForm.item_number.value == "30 dice") {
TheForm.amount.value = "20.00";
}
// -->
</SCRIPT>
But it doesn't seem to be tripping that if statement...or anything else I put in there for that matter. I named the form `orderform` and renamed the submit button to cmdsubmit
-
I hit some a javascript chan on IRC and someone suggested I catch the input before its sent to paypal and add the extra value. here's what I came up with:
<SCRIPT FOR="cmdsubmit" EVENT="onclick" LANGUAGE="JavaScript">
<!--
var TheForm;
TheForm = document.orderform;
if (TheForm.item_number.value == "30 dice") {
TheForm.amount.value = "20.00";
}
// -->
</SCRIPT>
But it doesn't seem to be tripping that if statement...or anything else I put in there for that matter. I named the form `orderform` and renamed the submit button to cmdsubmit
Wouldn't the TheForm.item_number.value == "30 dice" part need to be 30_dice??
-
I tried that combination too with no change.
-
<script>
function updateCost(item)
{
if (item=="15_Dice")
{
<<FORMNAME>>.ammount.value = "10.0";
}
}
</script>
<input name="item_number" type="radio" value="15 dice" onclick='updateCost(15_Dice);'>
<input type="hidden" name="amount">
That should work for you... I can't test it where I am now. Let me know how it goes.
PS I forgot you have to change <<FORMNAME>> to the name tag of your form. :)
So the syntax for the update is <<formname>>.<<inputname>>.value
You could then add an if for each you want to do.
-
I had to make a couple minor changes to the code but it works perfectly! Thank you!