I have checked the overlapping of time by taking the values into an array and sorting them.
here im unable to insert data into cells when the cells are empty!
my code:
Expand|Select|Wrap|Line Numbers
- <script>
- function compare_row_time()
- {
- var all_times= new Array();
- var flag_check=false;
- var count_times=0;
- for(var i=0;i<mygrid.getRowsNum();i++)
- {
- var time_1=mygrid.cells2(i,1).getValue();//starttime value of i
- var time_2=mygrid.cells2(i,2).getValue();//endtime value of i
- all_times[count_times]=time_1;
- count_times++;
- all_times[count_times]=time_2;
- count_times++;
- }
- var sort_times= new Array();
- sort_times=all_times.sort();
- for(var j=0; j<sort_times.length;j++)
- {
- if(sort_times[j]==sort_times[j+1])
- {
- flag_check=true;//if false data is inserted even it is wrong.
- }
- }
- return flag_check;
- }
- function save()
- {
- if(!compare_row_time())
- {
- myDataProcessor.sendData();//sending data to server
- }
- if(err_str!="")//error_msg
- alert(err_str);
- err_str="";
- }
- </script>
2.If im inserting new values into empty rows im not able to send data(if i change flag_check to false in [sort_times array]im able to insert values but if i give duplicate values also the data is getting inserted.this condition is false)
3.My pattern for time is user can enter time as 05:00 or 5:00 (if one row is having 5:00 & another row is having 05:00 it is not comparing; if the pattern is of same type it is checking for duplicates)
4.How can i highlight the duplicates cells & provide a message for it.
could anyone please reconstruct the above code without these errors.
thank you.
Regards
Narina