load csv file into a javascript file

May 15, 2009 at 12:59:29
Specs: Windows XP
Is this possible ? I am wanting to pull out a price of a product from the csv file and tie that price to its particular part number.

I am doing this for a website and I am learning script programming at the same time, and I am unsure how to do this.

The JS file would call the csv file and pull the price and part number out of it.

From there the JS file will create a form to use with a Paypal shopping cart.

This is the paypal shopping cart code for the add to cart button:

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="XXXXX">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="PartNumber1">
<input type="hidden" name="amount" >
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="cn" value="Add special instructions to the seller">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="weight" value=".5">
<input type="hidden" name="weight_unit" value="lbs">
<input type="hidden" name="add" value="1">
<input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHosted">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">


Using the variable I added to this button, the JS file would look similar to this:

function CalculateOrder(form)

if (form.item_name.value == "PartNumber1"
form.amount.value = (The price variable would go here);

if (form.item_name.value == "PartNumber2"
form.amount.value = (The price variable would go here);

What I need before this code in the JS file is the code that loads the csv file and outputs the price and part number. The JS file would search for the part number labelled called "PartNumber1" and output the appropriate price from the csv file.


See More: load csv file into a javascript file

Report •

May 18, 2009 at 10:00:57
See reply to "Importing .CSV"

Report •
Related Solutions

Ask Question