The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Paypal - Database - Script, Javascript form outputting USD values into a paypal shopping cart.
oddjobmj
post Jun 17 2008, 01:42 AM
Post #1


Newbie
*

Group: Members
Posts: 17
Joined: 17-June 08
Member No.: 5,916



Hello,

I am attempting to get a pre-existing javascript to output its data to a paypal shopping cart.

I don't know whether or not I would have to manage my own database for this, as to the effect that paypal manages the database for all the other cart options I have.

The script asks for two values - and then spits out a USD value and an estimated time of completion. I need the USD value to be sent to paypal through their e-commerce package. I have set up quite a few static "add to cart" buttons through paypal already. It has gone very well, but I cannot manage to get this dynamic output to function properly.

I have almost no experience with databases, but I get what they do. I just don't know how to code/manage them.

So, I'll go ahead and post my javascript here. The server that is hosting my site is compatable with the major database types. e.g. sql

CODE
    function Item(level,time,price) {
        this.level    = level;
        this.time    = time;
        this.price    = price;
    }
    //?????
    var ItemArr = new Array();

    var cur;
    cur = new Item(1, 1, 5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(2, 1, 3.18);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(3, 1, 1.18);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(4, 1, 0.58);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(5, 1, 0.68);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(6, 1, 0.48);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(7, 1, 0.38);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(8, 1, 0.6);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(9, 1, 0.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(10, 1, 0.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(11, 1, 0.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(12, 1, 0.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(13, 1, 0.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(14, 1, 0.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(15, 1, 0.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(16, 1, 1.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(17, 1, 1.6);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(18, 2, 1.6);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(19, 2.5, 1);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(20, 2.5, 1);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(21, 3, 1);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(22, 3, 1.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(23, 3.5, 1.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(24, 4, 2);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(25, 4, 2);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(26, 4.5, 2);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(27, 4.5, 2.2);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(28, 4.5, 2.2);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(29, 6, 3.1);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(30, 6, 3.1);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(31, 6.5, 3.1);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(32, 6.5, 3.1);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(33, 6.5, 3);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(34, 7, 3);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(35, 7, 3);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(36, 7.5, 3);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(37, 7.5, 3);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(38, 7.5, 3);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(39, 8, 3.4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(40, 8, 3.4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(41, 8.5, 3.4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(42, 8.5, 3.4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(43, 9, 3.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(44, 9, 3.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(45, 10, 4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(46, 10, 4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(47, 10, 4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(48, 11, 4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(49, 11, 4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(50, 11, 4.22);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(51, 11, 4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(52, 11.5, 4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(53, 10.5, 4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(54, 10, 4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(55, 10, 4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(56, 10, 4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(57, 10, 4.4);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(58, 10, 4.19);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(59, 10, 5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(60, 15, 5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(61, 20, 10.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(62, 22, 10.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(63, 24, 11);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(64, 24, 11);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(65, 25, 11.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(66, 25, 11.9);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(67, 25, 12);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(68, 25, 12.5);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(69, 25, 12.9789);
    ItemArr = ItemArr.concat(cur);
    
    cur = new Item(70, 25, 12.999878);
    ItemArr = ItemArr.concat(cur);
    


    //????
    function doCacl(form)
    {
        //????????
        var beginlevel    = form.beginlevel.value;
        var endlevel    = form.endlevel.value;
        //???????????
        if ((beginlevel == "") | (endlevel == "")) {alert("please enter your level");return false;}
        //??????????????
        if (beginlevel * 1 > endlevel * 1){alert("please enter your level");return false;}
        if ( endlevel * 1 > 70 ){alert("please enter your real level");return false;}
        
        if (( endlevel * 1 < 11 ) | (beginlevel * 1 < 1 ))
        {
        alert("Please choose a correct level range");  
        document.thisformonly.price.value ="";
        document.thisformonly.totaltime.value ="";  
        return false;
        }
        //??????
        var price = 0;
        var totaltime = 0;
        //????
        for (var i=0;i<ItemArr.length;i++)
        {
            if ((ItemArr[i].level * 1 > beginlevel * 1 )&(ItemArr[i].level * 1 <= endlevel * 1))
            {
                price        = price + ItemArr[i].price;
                totaltime    = totaltime + ItemArr[i].time;
            }

            if (ItemArr[i].level * 1 > endlevel * 1){i=ItemArr.length;}
        }
        if ( price < 1 ){alert("Please choose a correct level range");return false;}
        if ( totaltime < 24 ){alert("Please choose a correct level range");return false;}
        if (price>=100)
        {
        form.price.value        =  parseFloat(price).toFixed(2);
        form.score.value        =  Math.round(parseFloat(price).toFixed(2)*0.1);
        }
        if(price<100)
        {
        form.price.value        =  parseFloat(price).toFixed(2);
        form.score.value        =  Math.round(price*0.1);
        }
        form.totaltime.value    = totaltime;
        
    }
\


Here is an example of one of the paypal "add to cart" buttons.

CODE
<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Order Now!','','images/order_ordernow_rollover_09.jpg',1)"><div align="right"><form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" src="http://www.platinum-leveling.com/images/addtocart.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="Payment@platinum-leveling.com">
<input type="hidden" name="item_name" value="Custom Power Leveling">
<input type="hidden" name="item_number" value="10">
<input type="hidden" name="amount" value="140.00">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://www.platinum-leveling.com/contact/thankyou.php">
<input type="hidden" name="logo_custom" value="http://www.platinum-leveling.com/images/viewcart.gif">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-ShopCartBF">
</form></div></a>


I essentially want

CODE
price        = price + ItemArr[i].price;
(Or atleast, the "price" part - whatever that would be)

in my javascript to replace "140.00" in my paypal button code.

CODE
<input type="hidden" name="amount" value="140.00">


That way, whenever someone enters their values and gets a quote, they can add that value to their paypal cart.


Here is a link to the page with the javascript forms working.

http://platinum-leveling.com/order.html

Whether I use the "continue" or "order now" button isn't important to me.
Any suggestions?

Thank you for your time!

This post has been edited by oddjobmj: Jun 17 2008, 01:58 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Jun 17 2008, 11:20 PM
Post #2


Jocular coder
********

Group: Members
Posts: 2,224
Joined: 31-August 06
Member No.: 43



QUOTE
I am attempting to get a pre-existing javascript to output its data to a paypal shopping cart.


Then I don't think this is a database question. You simply need to modify the javascript code to put the appropriate (money) amount in the form for the PayPal payment link.
You might try reposing in javascript.

(I think it is a much better answer to have your own server side form that generates a PayPal link, having recorded all the details you need. But that's more work...)


--------------------
Brian Chandler
Nothing in this post constitutes "commercial solicitation". PayPal does not solicit residents of Japan. Contents may settle in transit. "Legal mind" may or may not be brain-damaged.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
oddjobmj
post Jun 20 2008, 05:16 PM
Post #3


Newbie
*

Group: Members
Posts: 17
Joined: 17-June 08
Member No.: 5,916



QUOTE(Brian Chandler @ Jun 17 2008, 11:20 PM) *

QUOTE
I am attempting to get a pre-existing javascript to output its data to a paypal shopping cart.


Then I don't think this is a database question. You simply need to modify the javascript code to put the appropriate (money) amount in the form for the PayPal payment link.
You might try reposing in javascript.

(I think it is a much better answer to have your own server side form that generates a PayPal link, having recorded all the details you need. But that's more work...)


I apologize. I was under the impression that the only way to do it was through a database. Thank you for the response!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Jun 20 2008, 10:14 PM
Post #4


Jocular coder
********

Group: Members
Posts: 2,224
Joined: 31-August 06
Member No.: 43



Basically a database stores information. What you need to do is simply to convert the information about the order from one form to another.

Apologies for the mysterious typo, by the way. You have probably spent several days trying to work out if I was accusing you of being a poseur, or inviting you to lie down. I meant *reposting* in the javascript forum, of course.


--------------------
Brian Chandler
Nothing in this post constitutes "commercial solicitation". PayPal does not solicit residents of Japan. Contents may settle in transit. "Legal mind" may or may not be brain-damaged.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
oddjobmj
post Jun 21 2008, 12:42 PM
Post #5


Newbie
*

Group: Members
Posts: 17
Joined: 17-June 08
Member No.: 5,916



Haha! I appreciate your concern, but I actually missed that typo! Pretty funny now that you mention it. laugh.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 22nd September 2014 - 07:10 AM