...

View Full Version : A simple calculation



bubbaryu
07-31-2008, 03:33 AM
I have a project i am working on. What I need is 5 variables, these 5 variables will be entered (input values) by the user, then these 5 values will be multiplied to the numbers (1,2,3,4,5) based on what column the input boxes are under, the totals for each of the five numbers then will be added up to a grand total. after that the number (grand total) will be divided by the total of the first 5 variables. basically it is a series of math equations...but what i need to know is how to get the values that are entered by the user and have them modified by the code....If you can or any one, can help me just getting the values entered by the user in to the code to do all these math equations i should be able to take it from there...

This is the code i used to test a a field but because i dont know JS that well...im stuck



var a

function test()
{

var a = document.getElementById("inputTest");
alert(a)


}


yet i get this error "[object HTMLInputElement]"

why? If this is to much or not the right place for this question i do apologize, and i would like to say thank you in advance to any one who is willing to help me.

BWiz
07-31-2008, 03:45 AM
you need to add .value to the end of the document.getElementById line if you want the value of said field.

bubbaryu
07-31-2008, 03:48 AM
you need to add .value to the end of the line if you want the value of said field.

thanks for the quick response =)
...now it says undefined. =/



function calculate()
{

var a = document.getElementById("test").vaule ;
alert(a)


}

BWiz
07-31-2008, 03:50 AM
".value" not ".vaule"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum