Click to See Complete Forum and Search --> : Adding Numbers


vfierro
01-12-2004, 03:01 PM
I am stuck on what appears to be simple issue, adding two number together.

That darn concatenate thing keeps messing me up. I have tried searching google on "arithmetic operands java" for any help with no avail. All I want to do is assign "y" the value of "x1+x2".

This shouldn’t be this hard. Please any assistance would be greatly appreciated.

Thanks in advance.

<script language="JavaScript">

function s5_calculate(){
with (document.order_form){

y.value=x1.value.+ x2.value;

}
}
</script>

<form name="order_form" ACTION="/cgi-bin/script.pl" METHOD="POST">

.....


<td width="113"><input type="text" name="y" size="16" tabindex="16"
onclick=s5_calculate() value=""
onblur=s5_calculate() value=""></td>


......


Just trying to fill the value of a text box.. y = x1* x2 works , y = x1 / x2 works, y = x1- x2 works

so... if x1 = 8 and x2 = 4

The values if get for y are y=8*4 y=32, y=8\4 y=2, y=8-4 y=4 , y=8+4 y=84

When I use the "+" sign a concantation occures.

That is my issue... I believe.?

Pittimann
01-12-2004, 03:07 PM
Hi!

You can convert the values to numbers or use:

y.value=(x1.value + x2.value);

Cheers - Pit

IsmAvatar
01-12-2004, 03:09 PM
y.value=x1.value.+ x2.value

err, there's a period before the plus sign. I don't know javascript very well, but I know that most languages would return an error if they saw that. position 16.