Sometimes when using JavaScript for calculations, JS treats numbers as string when I use + (addition). If this happens, you can use - (subtraction) and multiply with -1 (negative 1). This forces JS to treat the number string as a number. Very useful in loops, and when getting the number string from e.g. window.document.all.elemID.innerText
: var a=window. document.all var total=a(id1).innerText- (a(id2).innerText*-1) alert(total)
Requires Free Membership to View
Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.
This was first published in May 2003