Results 1 to 2 of 2

Thread: for loop wont return highest target but end of list

  1. #1
    Join Date
    Dec 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default for loop wont return highest target but end of list

    I cant figure out why this wont return the highest target. The variable highest_target is placed outside the for loop.

    Code:
    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
    }

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Your code doesn't return anything.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •