Calculation...

  • Thread starter Thread starter 116
  • Start date Start date
1

116

I have a web page with results and a form. The results section displays my
last entry (numerical). On my form, I have one field that is merely the
result plus one. I have been trying to get the result plus one to populate
the filed in my form. I have been trying to get this to work with no luck.
Any help would be greatly appreciated.

Thanks
David
 
All that comes to my mind is that + is also concatenation operator, so 1+1
could equal 11 if one of them is a string

To force addition, make sure that both are numeric. Using JavaScript you can
force a string to a number by parseInt()
http://www.w3schools.com/jsref/jsref_parseInt.asp or just by doing
arithmetic e.g. value *1 will convert a string in value to a number

What results have you been getting?
What code have you used ?
or if you only use the FP menus (or even if you don't )
What is the URL?
 
Not very knowledgable on Java. I had been trying to alter a sample piece of
script I previously located. And yes, there both numbers.

David
 
So can you post your code (or a link to your site).

It is more likely that JavaScript is (or needs to be) used, not Java. The
two are completely different.

If you are using JavaScript, it isn't always easy to tell what are numbers
and what are strings. Any value returned from a form input is a string even
if it looks like a number
 
Hello Trevor,

This is what I sample from...
function calcinc()
{
with (document.FrontPage_Form1)
{ PPNON.value = +PPNON.value + +"1";
if (PPNON.value < 10)
PPNON.value = '0' + PPNON.value;
else if (PPNON.value >= 10)
PPNON.value = '' + PPNON.value;
}
/* Note the extra + operators. */
}
</script>

and play with when needed.

David
 
Back
Top