Applescript & Javascript to get number from chrome and give a total I'm trying do get every totals from an internal webpage and get the total.

for getting a single result I wrote this :

tell application "Google Chrome"
    tell tab 1 of window 1 to set orderTotal to execute javascript "document.getElementsByClassName('total')[0].innerHTML;"
end tell 


the output on this example is :

"&lt;td&gt;1,200.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;"


(PS the currency is not always the same)

for getting every value this work 

tell application "Google Chrome"
    tell tab 1 of window 1 to set r to execute javascript "var outPut=[]; var arr=document.getElementsByClassName('total');for (var i in arr) {outPut.push(arr[i].innerHTML)};outPut;"
end tell
 return r


which give me something like this :

"&lt;td&gt;4,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;3,800.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", missing value, missing value, missing 


I would like to clear the text and do a total,

Tried this for clearing the values, but obviously not working :

set theText to Unicode text
property leftEdge1 : "&lt;td&gt;"
property rightEdge1 : "&lt;/td&gt;"
try
    set saveTID to text item delimiters
    set text item delimiters to leftEdge1
    set classValue to text item 2 of r
    set text item delimiters to rightEdge1
    set singleValue to text item 1 of classValue
    set text item delimiters to saveTID
    singleValue
end try


and for the total I'm not sure yet how to proceed.
In that absence of the actual URL and what appears to be incomplete output shows in the OP the following example AppleScript code defines r as a list and sums its numeric values.

set r to {"&lt;td&gt;4,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;3,800.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", "&lt;td&gt;5,000.00&lt;/td&gt;&lt;td&gt;JPY&lt;/td&gt;", missing value, missing value, missing value}

set theText to Unicode text
property leftEdge1 : "&lt;td&gt;"
property rightEdge1 : "&lt;/td&gt;"
set totalValue to 0

repeat with i from 1 to count r
    try
        set saveTID to text item delimiters
        set text item delimiters to leftEdge1
        set classValue to text item 2 of item i of r
        set text item delimiters to rightEdge1
        set singleValue to text item 1 of classValue
        set text item delimiters to saveTID
        set totalValue to totalValue + singleValue
    end try
end repeat

log totalValue

-- Result:
-- 42800




Note: The example AppleScript code is just that and does not employ any other error handling then what's shown and is meant only to show one of many ways to accomplish a task. The onus is always upon the User to add/use appropriate error handling as needed/wanted.