Jeremy wrote:
[snip]
So I can folow Martin Honnen's suggestion and do this:
document.forms.grid.p_row.value=document.forms.gri d.p_row.value*1+10;
Martin didn't suggest that, exactly. The FAQ entry he pointed you to
describes no less than six means of performing string to number type
conversion.
or yours and do this:
document.forms.grid.p_row.value=+document.forms.gr id.p_row.value+10;
One of those methods was unary plus.
Both appear to work equally well - does it matter which - is one a
"better" method and if so, why?
If you'd followed the link to the FAQ notes, you'd have a partial answer
to that. The unary plus operator is the fastest, though it sometimes
better to wrap the expression in parentheses:
(+string)
For explicitness, the Number constructor function called as a function
is another good alternative:
Number(string)
I wouldn't recommend operator trickery like multiplying by 1 or
subtracting zero as neither of these are primarily designed to perform
type conversion, whereas the other two approaches above are.
I recommend that you read the type conversion article[1] in the FAQ notes.
On a different note, there's little need to keep referencing form
controls from the document object. See "Efficient use of Form
Accessors"[2], part of another FAQ notes article.
Mike
[1] <http://www.jibbering.com/faq/faq_notes/type_convert.html>
[2] <http://www.jibbering.com/faq/faq_notes/form_access.html#faEff>