View Full Version : javascript form calculations

02-14-2007, 10:20 AM
I have a form containing 12 drop down lists to enable a user to configure a machine. At the bottom of the page there is an "update price" button which when hit looks at the options selected and then indicates cost of the machine. This all works fine. (I must sya I did not write all the coding for this, but have tweaked the original to suit).

I wish to accomplish two things:

1: I want the drop down lists to read a value from somewhere else other than the hard coding inside the form, so that prices can be more easily updated by anyone, without looking at the coding of the page.
Currently price is pulled for example from (11270 is the price).

else if (form.machine[2].selected){
pr_flag =11270;

the dropdown list coded as for example

<P><SELECT name=machine id="machine">

2: The second thing I would like to do is have just one form that caters for a whole range of machines. The current form is just for one particular machine.
The idea I had in mind was to add another dropdown list with all the machine types in it, then when one is selected somehow it reads the correct data for prices for that particular machine.

I am not sure if both of these options can be accomodated in the one form and if they can I dont know where to start, so some help would be appreciated.

Mr J
02-14-2007, 02:54 PM
Can you post a url to an example page?

02-15-2007, 09:30 AM
Note: this link is not my site but for the purposes of what I am trying to achieve the coding is similar. The calculator I am trying to develop is not for publishing on the internet (internal use only).


Mr J
02-15-2007, 03:22 PM
One other option would be to use arrays to dynamically populate the selectboxes but this might not be as easy as hard coding in the page.

Take a look at this example which populates just 3 selectboxes and then imagine the arrays needed for 12 selectboxes, not for the faint hearted


02-15-2007, 07:15 PM
I see what you mean, it would turn into a marathon, maybe I'll stick to the hard coding.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum