Add and subtract

  • Thread starter Thread starter ReidarT
  • Start date Start date
R

ReidarT

I have a javascript where I try to add 1 to a value through a button and
show the value in a textbox
and subtract 1 from another button and show the result in the same
textfield.
This seems to work with subtraction but the addition just treats it like a
string .
If the value is in the label is 22 and I press the Add-button, I get 2222.
When I click the subtract button I get 2221 (the correct value)

<script language="javascript" type="text/javascript">
function LeggTil() {
var Tall = document.Form1.lblDayHtml.value;
var Tall2 = Tall + 1;
document.Form1.lblDayHtml.value = Tall2;
}
function TrekkFra() {
var Tall = document.Form1.lblDayHtml.value;
var Tall2 = Tall - 1;
document.Form1.lblDayHtml.value = Tall2;
}
</script>


regards
Rehiaa
 
function addem(){

Operand1 = parseInt(document.forms("MyForm").OP1.value)
Operand2 = parseInt(document.forms("MyForm").OP2.value)
document.forms("MyForm").Result.value = Operand1 + Operand2

}
 
Reidar,

What has this to do with C#.

I thought (not sure anymore) that I used for this kind of behaviour

var Tall = 0;
Tall = 0 + document.Form1.lblDayHtml.value;

etc.

:-)

Cor
 
Back
Top