PDA

View Full Version : for loop wont return highest target but end of list



chrisdab
01-14-2009, 07:12 PM
I cant figure out why this wont return the highest target. The variable highest_target is placed outside the for loop.


var highest_target;
var inputs = divs[i].getElementsByTagName('INPUT');
var bounty_target = 'http://apps.facebook.com/mobwars/fight/do.php?';
var target_id = '';
var bounty_id = '';
var bounty = parseInt(dollars_to_int(divs[i].parentNode.parentNode.getElementsByTagName('TD')[2].innerHTML));
for (var j = 0; j < inputs.length; j++)
{
bounty_target += inputs[j].name + "=" + inputs[j].value + "&";
if (inputs[j].name == "target_id") target_id = inputs[j].value;
if (inputs[j].name == "bounty_id") bounty_id = inputs[j].value;
}
var highest_target_id; //for debug message only
var bounty = parseInt(dollars_to_int(divs[i].parentNode.parentNode.getElementsByTagName('TD')[2].innerHTML));
debug_msg += '<font color=red>' + bounty + '</font><br />';
GM_log(bounty);
if ((bounty < boss.preferences.bounty_max || boss.preferences.bounty_max == 0) && bounty > boss.preferences.bounty_min && bounty > highest)

{
target_acquired++;
highest = bounty;
debug_msg += '<font color=red>' + highest + '</font><br />';
GM_log("highest " + highest);
highest_target = bounty_target;
highest_target_id = target_id; //for debug message only
}

jscheuer1
01-15-2009, 06:14 AM
Your code doesn't return anything.