...

View Full Version : Textfield value + Textfield value = Other textfield value



Datis
09-17-2011, 09:53 PM
Hey folks, I have a little problem here, I have two textfield and a botton

Text fields:




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

xelawho
09-17-2011, 10:08 PM
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)
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum