javascript - Looping over array of objects -


i'm working on asp.net app utilizing lot of jquery ui controls particularly datepicker.

in web service making call database , retrieving list of objects , passing them javascript parse them out array containing 1 or more objects this:

javascript object http://s7.postimage.org/9nsq80rnv/json_object.png

i need include kind of logic in can loop through array of objects , check see if javascript date falls in between enddate , startdate properties of object can apply css style datepicker. first question, there way convert enddate/startdate property format valid javascript date? , if how can iterate on array , apply logic see if date falls inside range?

any appreciated!

edit: noticed image here kind of hard see can more read properties here:

image link

as requested here example code:

function createdaterangesforcalendar() {     $.ajax({         type: "post",         url: "../services/bookingservice.asmx/getcalendardateranges",         contenttype: "application/json; charset=utf-8",         datatype: "json",         async: false,         success: function (response) {             dateranges = $.parsejson(response.d);         },         error: function (xhr, textstatus, thrownerror) {             alert(textstatus);             alert(thrownerror);         }     }); }  function markinvaliddates(date) {      var isholiday = false;     dmy = date.getdate() + "-" + (date.getmonth() + 1) + "-" + date.getfullyear();      isholiday = checkisholiday(date);      if ($.inarray(dmy, invaliddays) == -1) {          (var = 0; < dateranges.length; i++) {             // if date falls in between start , end date of object[i] return like: return [true, "holiday", "holiday rates apply - minimum 14 days"];             // else loop through next object , try there             }           if (isholiday == true) {             return [true, "holiday", "holiday rates apply - minimum 14 days"];         } else {             return [true, ""];         }     } else {         return [false, "unavailable", "unavailable"];     } } 

first question, there way convert enddate/startdate property format valid javascript date?

the format seems this: /date(milliseconds)/. valid js date object can obtained this: new date(s.match(/date\((\d+)/)[1]).

and if how can iterate on array , apply logic see if date falls inside range?

var re = /date\((\d+)/; for(var in arr) {     var start = new date(arr[i].startdate.match(re)[1]),         end = new date(arr[i].enddate.match(re)[1]);     if(mydate < end && mydate > start)         // something. } 

the above seems answer question, way understand it.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -