tags:

views:

26

answers:

1

I have two list boxes(A,B) with some duplicate values and i can send values from A to B or B to A using send button and i have one save button.

For the first time without sending any list box if i click on save button i am showing message like "NO changes or Done"

But once i send one item from A to B and again sending that same item from B to A it means no changes or Done. here also i want to show same message "NO changes or Done" .but i am unable to find the staus can any one pleasse give code or tips to find the default status for listboxs in javascript.

Thanks

+1  A: 

I would store the default values of each list boxes in a (global) array on the page load. Then I would call a function to test if the currentValues of the listbox against the default values.

var arrLstBoxDefaultValuesOfA = [5,7,9,10];
var arrLstBoxDefaultValuesOfB = [11,14,12,17];

function isListBoxDefault(arrLstBoxDefaultValues, arrCurrentValuesOfListBox){

  for (var i=-1,currentValue;currentValue=arrCurrentValuesOfListBox[++i];){

    var currentValueDoesNotBelongToDefaultValue = 
          arrLstBoxDefaultValues.indexOf(currentValue) == -1;

         if (currentValueDoesNotBelongToDefaultValue == false){
                 return false;
                     }
   }

 return true;
}; 

I hope it can give you a useful idea. burak ozdogan

burak ozdogan