Forum Moderators: open

Message Too Old, No Replies

javascript on page load

         

magnetooo

7:18 pm on Aug 11, 2011 (gmt 0)

10+ Year Member



Hello,

I basically have a javascript file that acts as a database for prices.

price1 = 1000;
price2 = 4000;
price3 = 8000;
price100 = 5000;


What i want to do, is based on page load, to execute this script.
What is the best way to call these prices? class, id?

I started populating some tables, but i found out that some prices showed and others didnt. Anyone have a clue on this?

Much Appreciated.

lucy24

3:21 am on Aug 17, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That dead silence you hear is several dozen people trying to think of a nice way to say that this is really pushing the limits of javascript and you probably want php ;)

Does "price100" imply that you have a whole lot of prices? I hope you are storing them in an array, or several arrays, or one multi-dimensional array.

I think it would have to be done by id. And, again, that's a colossal lot of ids. In fact "price1, price2" etc is probably as good as you're going to get. Pull the items into your javascript. Or push them out of it; it's not totally clear which you're doing. Somewhere in the middle, go to a quick subroutine to toggle between prices[n] (the javascript array that stores your data) and "price" + n (the string that acts as the corresponding id).

I started populating some tables, but i found out that some prices showed and others didnt. Anyone have a clue on this?

Not without recourse to a crystal ball. Or to more information that you've given so far.