#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    56
    Rep Power
    31

    Integer versus strings


    Code:
    $('tr[name=itemrow]').each(function()
    	{
    	var $price = $(this).find('input[name="price[]"]').val();
    	var $item = $(this).attr('which');
    	if(sellvalue[$item] > $price)
    		{
    		$(this).find('b').wrap('<font color="red"/>');
    		}
    	});
    I've figured out that $price is a string, and though you cannot see the declaration of the array sellvalue it's an array of strings too. This means 750 is greater than 10,000.

    How do I make it treat $price and sellvalue[$item] as integers so that 750 is less than 10,000?
  2. #2
  3. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Location
    London, UK
    Posts
    4,004
    Rep Power
    2793
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    56
    Rep Power
    31
    Awesome! Thank you Winters!

    All my searches for something like pascal's strtoint were fruitless, I just didn't know what to search for.

IMN logo majestic logo threadwatch logo seochat tools logo