473,385 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

checking time overlap

20
Hello

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
  1. <script>
  2. function compare_row_time()
  3. {
  4.   var all_times= new Array();
  5.   var flag_check=false;
  6.   var count_times=0;
  7.   for(var i=0;i<mygrid.getRowsNum();i++)
  8.   {
  9.     var time_1=mygrid.cells2(i,1).getValue();//starttime value of i
  10.     var time_2=mygrid.cells2(i,2).getValue();//endtime value of i
  11.     all_times[count_times]=time_1;
  12.     count_times++;
  13.     all_times[count_times]=time_2;
  14.     count_times++;
  15.   }
  16.   var sort_times= new Array();
  17.   sort_times=all_times.sort();
  18.   for(var j=0; j<sort_times.length;j++)
  19.   {
  20.     if(sort_times[j]==sort_times[j+1])
  21.      {
  22.        flag_check=true;//if false data is inserted even it is wrong.
  23.      }
  24.   }
  25.    return flag_check;
  26. }   
  27.  
  28. function save()
  29. {
  30.   if(!compare_row_time())
  31.    {
  32.     myDataProcessor.sendData();//sending data to server
  33.    }
  34.   if(err_str!="")//error_msg
  35.   alert(err_str);
  36.    err_str="";
  37. }
  38. </script>
  39.  
1.Here in sort_times array if any duplicate values are present it will show error(this is only working when im checking with existing data in grid)
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
Apr 5 '12 #1
1 2376
narinas
20
i have checked the loop with counters and alerted the time_1 & time_2 values
im getting as output as
for loop j:
counter from 0 to 7
time_1 time_2
6:00 undefined
16:02 7:00
8:00 16:30
17:00 09:00
18:02
but actual data is

time_1 time_2
6:00 7:00
16:02 16:30
8:00 9:00
17:00 18:02

when im alerting message for overlapped cell its showing alert for last row every time,
the problem is with setting flag_status=true;
Apr 5 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Shaun | last post by:
Hi, I have a table called Bookings which has two important columns; Booking_Start_Time and Booking_End_Time. These columns are both of type DATETIME. Given any day how can I calculate how many...
15
by: cody | last post by:
We have a huge project, the solutuion spans 50 projects growing. Everytime I want to start the project I have to wait nearly over 1 minute for the compiler to complete building. This is...
0
by: dag | last post by:
Hi! I would like to do an overlap window, over my main window (of my application), with a Progress Bar. Exactly when I push a button of my application I want show a window, with a Progress bar,...
10
by: soup_or_power | last post by:
Hi I have a requirement to compare the user entry for mm/dd/yy/HH/mm (month, day, year, hour, minute) to the Easter Standard Time. I am using the following script, but it is not giving the right...
13
by: Mike S | last post by:
I came across the following paragraph in the "Semantics" section for simple assignment in N1124 (C99 draft) and I'm wondering if I'm interpreting it right: 6.5.16.1p3: If the value being...
2
by: Rombolt | last post by:
Hi I have a MSSQL table with many time intervals stored as datetime. Each time interval is also assigned a numeric type that specifies what type of job was done during the time interval. I need to...
8
by: pnsreee | last post by:
Hi all I have a time in this format 12:00p,1:20A . In linux i am using following regexp to check it. egrep '|:(0|1)' $time. I am trying to achive this in perl. Please help me regarding...
8
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi just wondering if anyone had any ideas on how to do this in C#. I am trying to get the total time of several start and stop time data entries. For example the input data looks like starttime...
10
by: pyotr | last post by:
Simply my problem is: I need to validate the StartDate and EndDate when entered for an employee through subform. the purpose is to avoid entering a date that violate or overlap date intervalS that...
5
by: liketofindoutwhy | last post by:
It seems like there are only 4 methods to overlap 2 images using CSS? There are two images, each with its own URL. Using CSS, there seems to be 2 ways to overlap them (the task is actually to put...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.