WPIntell

Source evidence

Javascript Addition Not Working

Custom CSS and JavaScript · support · 2018-04-19T03:27:00+00:00

mixedsentiment
mediumseverity
0.67relevance
1replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

5 / 35 rows with source links

14.3% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

30 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
carl2e resolved
This is probably has a simple answer but I have been working on this for hours without being able to figure it out. I have the following function that retrieves a value ‘spot’ from input field ‘myInput’ and calculates a value ‘tmpspot’. For this example I am entering the number ’23’ in the field “myInput” (type=”number”). When I pass ’23’ to the function as shown below the function properly returns ’44’. However, when I comment out the line “tmpspot = tmpspot – (0 – spot) ;” and instead use the previous line “tmpspot = tmpspot + spot ;”, the function returns ‘2123’, as though it concatenated the two numbers instead of adding them together. What am I missing? function NextSpot() { var spot = document.getElementById(“myInput”).value; var tmpspot = spot % 2 ; tmpspot = (tmpspot – (0 – spot)) – 1 ; tmpspot = 65 – spot ; tmpspot = tmpspot / 2 ; tmpspot = parseInt(tmpspot); // tmpspot = tmpspot + spot ; tmpspot = tmpspot – (0 – spot) ; document.getElementById(“demo”).innerHTML = tmpspot ; return true ; } I realized that php was treating the variables as string variables, not numeric variables. For now, I including the following line to make sure that the variable ‘spot’ is an integer: spot = parseInt(spot) ; The function is now working.

Comments

1 shown
carl2e 2018-04-19T13:09:00+00:00

I realized that php was treating the variables as string variables, not numeric variables. For now, I including the following line to make sure that the variable ‘spot’ is an integer: spot = parseInt(spot) ; The function is now working.