Sorry for the vague title, but I have 2 javascript functions that display the value that was set on one of the options in a form selection box. Now I want to add a third function that will sum the values from the user's selections by pressing a button.
So in a div with id value1 and a div with id value 2 the values from the user's selection will appear. No I'm trying to get a function to sum both values by clicking a button.
Whatever I try, nothing seems to work. Any help would be highly appreciated. Many thanks in advance!
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".") - W3C Recommendation - http://www.w3.org/TR/html4/types.html
Thanks Kor! I've changed the name and ID tags. The problem is that I don't know how to write a function that sums the values and presents a total when you press a button. Would you be able to help me with that?
What the current script does is displaying the value that belongs to option that the user selects.
The code above wil display 2 numbers. The top number will be either 1 or 2 and the bottom number can range from 1 to 4. This is what I want it to do.
But I also want to sum those 2 selections and display a total. And I just can't figure out how to do this.
Would anybody be able to help me with this? Your help is highly appreciated! Many thanks!
Hi ryan,
Thanks for your help. Would you be able to show me how to put that into code? I'm not sure how to create a variable that is equal to the result of the user's selection for value 1 and 2.
Yes, I thought you meant you wanted the summation to occur all within the same function (window.load). Right now, value and value2 are only in scope to the window.load function. Either place the summation code in there or make the value and value2 variable global in code.
Bookmarks