If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Need help to calculate total amount based selection options in form

HI

I am new to Javascript and struck up in middle of my assignment.
I have developed a html page which contains a form of radio buttons,drop down list and check box and now i want a function when click on calculate button should update the total amount field text box based on the selection of radio buttons(type of item),drop down list(quality of image) and check box(glossy finish,if it is selected $1 is added if not no value) and quantity value.

STOP using $ prefix on JavaScript variable names...
Please remember to wrap any code you have in forum tags:- [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]If you can't think outside the box, you will be trapped forever with no escape...

Ok, I just spent 30 minutes fiddling around and decided that you would be better off using a data object to hoe the types of merchandise and the costs of the various elements of your assignment.

I also decided on setting up your form so that it not only removes any initial start up problems by ensuring that the radio and select elements have initial selected elements but also set the input quantity box to have an initial value of 1

The form I designed calculates the value of the order based on the selection and the names of the fields helps with drawing data from the data object that stores the merchandise types and arrays of the values of the merchandise cost.

You didn't say if glossy finish is $1 extra per print or just an extra $1 on top of the order quantity value so in my script it is calculated as $1 for each copy wanted.

Then a short 9 line function is used to access form data, pull values from the data object and output a price.

IMHO this would be a simpler method as it is easily edited.

If you want to post up your answer, I can give you some pointers on how you can amend your script, I am not going to do homework, it is for you to do and learn from the advice given and you will need to experiment yourself with your ideas as you will have to be able to explain what is going on in your script if the teacher asks you about the script.

STOP using $ prefix on JavaScript variable names...
Please remember to wrap any code you have in forum tags:- [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]If you can't think outside the box, you will be trapped forever with no escape...