cougar23 Posted October 15, 2008 Share Posted October 15, 2008 In and calendar/scheduling UI, I have two JS arrays (originalTimeSlots & currentTimeSlots) that store boolean values on if the checkbox for that time slot is selected or not. They are both associative arrays with the index/key being in the format "DATE;APPT_START_TIME;APPT_END_TIME", i.e. originalTimeSlots["2008-11-17;08:00:00;09:00:00"] = true; The original array holds the values of the checkboxes on load of page, while current holds the values after the user has (potentially) made changes by selected one or more slots and clicks a button to submit. What I want to do is loop through both arrays comparing the values of the matching pairs and set a variable once one is found to be different. I tried two FOR loops but the length is coming out as zero(0). How can I do what i'm trying to do? var nothingChanged = false; for(var i = 0; i < originalTimeSlots.length; i++) { for(var j = 0; j < currentTimeSlots.length; j++) { if(originalTimeSlots[i] != currentTimeSlots[j]) { nothingChanged = true; return; } } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.