Updated JavaScript "On value" function.