Calculation...


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
 
Ad

Advertisements

T

Trevor Lawrence

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?
 
1

116

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
 
T

Trevor Lawrence

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
 
Ad

Advertisements

1

116

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top