JavaScript recognizes several types of data including: strings of characters (letters and numbers) and real or integer numbers. The data type affects the results of expressions using the + and += operators. If all the values in the expression are numeric, + performs addition. If one value is a string value, + concatenates.
Text boxes, list boxes, and drop-down boxes return string values, not numbers. If these strings are to be treated as numbers, JavaScript needs to be told to “parse” (change the value of) the string into a number.
JavaScript has two methods for parsing strings into numbers:
In Design mode, add three text boxes and a command button to a new or existing Dashboard section in Sample3.bqy, similar to Addition of Strings in Figure 2, Concatenation and addition of strings. Script the command button to add the values of the first and second text boxes, returning the result in the third text box.
Enter numbers in both the first and second text box and click the button. What is the result?