www.webdeveloper.com
Results 1 to 2 of 2

Thread: how to compare each record with previous record in a same list using javascript?

  1. #1
    Join Date
    Apr 2012
    Posts
    2

    Question how to compare each record with previous record in a same list using javascript?

    Hi all,

    as my below javascript code, i need to compare each id of my actions with previous actions id within that same list, and do something. But how do i do that? please help..

    Code:
    myFormResponse = function(responseXML) {
    var product = $(responseXML).find('product');
    			var status = $(product).find('status').first().text();
    			if (status == "SUCCESS") {
    			var actions = $(product).find('productActionsList');
    			
    				actions.each(function(i, v) {
    					var act = $(v).find('actLocationDTO');
    					var actLocId = $(act).find("id").text();
    					
    					//do comparison for each id with previous id
    				});
    			};
    thanks in advanced.

  2. #2
    Join Date
    Apr 2010
    Location
    Oslo, Norway
    Posts
    89
    create a variable storing the previous data, and check against it on each iteration.

    under var actions....
    Code:
    var previousData="";
    Then in the iterator-loop
    Code:
    if (data==previousData){
    
    }
    And finally, also inside the loop:

    Code:
    previousData=data;
    - Spinner
    Producer, Developer, Gamer, Father and Husband.

    Spinners Web-development blog

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles