Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    A simple calculation

    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

    Code:
    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.

  • #2
    Regular Coder BWiz's Avatar
    Join Date
    Mar 2006
    Location
    Sol System
    Posts
    471
    Thanks
    7
    Thanked 21 Times in 21 Posts
    you need to add .value to the end of the document.getElementById line if you want the value of said field.
    Last edited by BWiz; 07-31-2008 at 03:49 AM.
    BWiz :: Happy Coding!
    2006
    2007 2008 2009
    2010 2011
    Irrational numbers make no sense.

  • Users who have thanked BWiz for this post:

    bubbaryu (07-31-2008)

  • #3
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by BWiz View Post
    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. =/

    Code:
    function calculate()
    		{
    	
    	var a = document.getElementById("test").vaule ;
    	alert(a)
    
    
    			   }

  • #4
    Regular Coder BWiz's Avatar
    Join Date
    Mar 2006
    Location
    Sol System
    Posts
    471
    Thanks
    7
    Thanked 21 Times in 21 Posts
    ".value" not ".vaule"
    BWiz :: Happy Coding!
    2006
    2007 2008 2009
    2010 2011
    Irrational numbers make no sense.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •