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 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    41
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Post Textfield value + Textfield value = Other textfield value

    Hey folks, I have a little problem here, I have two textfield and a botton

    Text fields:

    Code:
    <input name="rate" type="hidden" id="rate" value="<%= rs_rating.Fields.Item("rate").Value %>" />
    
    <input name="plus" type="hidden" id="plus" value="1" />
    
    <input name="total" type="hidden" id="total"  />
    
    <input type="Submit" name="Submit" id="Submit" value="Course Rating " />
    Now what I want is something like this input "rate" value + input "plus" value which means if for example if rate (with dynamic value which could be any number) is 4 it will be 4+1 (1 is the static value of input "plus") which will be 5 and that 5 would be the value of input "total" that is the only text field which submit to DB. Just need the JS for that math problem.

    Thanks folks.
    Last edited by Datis; 09-17-2011 at 09:59 PM.

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,772
    Thanks
    55
    Thanked 518 Times in 515 Posts
    Code:
    html:
    <input type="button" value="Go!" onclick="myFunction()">
    Rate
    <input type="text" id="rate" value ="">
    Plus
    <input type="text" id="plus" value ="">
    Total
    <input type="text" id="total" value ="">
    
    js:
    function myFunction () {
    document.getElementById("total").value = parseFloat(document.getElementById("rate").value) + parseFloat(document.getElementById("plus").value)
    	}


  •  

    Posting Permissions

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