473,804 Members | 3,353 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Perform control schedule

263 Contributor
Hi there.

Hi have this script:

Expand|Select|Wrap|Line Numbers
  1.  <script language="javascript" type="text/javascript">
  2. <!--
  3.  
  4. var fieldNames = new Array("IRE", "ISI", "IMI", "REL", "REV", "MAN", "SOP", "GUF", "FOR", "VAS");
  5.  
  6. function loaded()
  7. {
  8.  
  9.   var tm, q = location.href.indexOf("?tm=");
  10.   if (q < 0 || (tm = location.href.substr(q + 4)).length <= 0) return;
  11.  
  12.  
  13.   tm = tm.split(";");
  14.  
  15.   var frmObj = document.timeForm;
  16.  
  17.   var re = /^([a-z]+)-(([01]\d|2[0-3]):[0-5]\d)$/;
  18.  
  19.   for ( var n = 0 ; n < tm.length ; n++ )
  20.     {
  21.       var rt = tm[n].match(re);
  22.       if (rt && typeof(frmObj[rt[1]]) != "undefined")
  23.         {
  24.  
  25.           frmObj[rt[1]].value = rt[2];
  26.         }
  27.     }
  28. }
  29.  
  30. function unloading()
  31. {
  32.  
  33.   if (window.opener == null) return;
  34.  
  35.   window.opener.popupWin = null; 
  36. }
  37.  
  38. function updateTime(txtObj)
  39. {
  40.   if (window.opener == null) return;
  41.  
  42.   var re = /^([01]\d|2[0-3]):[0-5]\d$/;
  43.  
  44.   if (txtObj.value.length >= 5 && !txtObj.value.match(re))
  45.     {
  46.       alert("Inserire l'orario nel formato 'hh:mm'.");
  47.       txtObj.focus();
  48.     }
  49.  
  50.   var frmObj = txtObj.form;
  51.   var elems = frmObj.elements;
  52.  
  53.   var result = "";
  54.   var destObj = window.opener.document.myform.impiego;
  55.  
  56.     {
  57.       for ( var n = 0 ; n < elems.length ; n++ )
  58.         {
  59.  
  60.           if (elems[n].type == "text" && elems[n].value.match(re))
  61.             {
  62.               if (result.length) result += ";";
  63.  
  64.               result += elems[n].name + "-" + elems[n].value;
  65.             }
  66.         }
  67.  
  68.       destObj.value= result;
  69.     }
  70.   else destObj.value= "--:--"; 
  71. }
  72.  
  73. // -->
  74. </script> 

To perform control schedule.
That is schedule no superior to 7 hours and 36 minutes.

For example:

1) In the field of the form "IRE" inserted 08:00... this value is superior to 7:36
Its' wrong !!!!


2) In the field of the form "IRE" inserted 04:00 and in the field of the form "ISI" inserted 04:00.... this value is superior to 7:36
Its' wrong !!!!

Help me please, regards
viki1967
Feb 13 '08 #1
19 2303
acoder
16,027 Recognized Expert Moderator MVP
For each field, get the hours and minutes by splitting the input using split(). Use parseInt to convert into a number. Then add them up. If the hours are more than 7, then validation fails. If the hours equal 7, but the minutes exceed 36, again the validation fails. If you get stuck, post your attempt.
Feb 14 '08 #2
viki1967
263 Contributor
Sorry I not understand... for example ?
Feb 14 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
For example, let's say you have 'field' which contains the input:
Expand|Select|Wrap|Line Numbers
  1. var vals = field.value.split(":");
  2. var hours = parseInt(vals[0]);
  3. var mins = parseInt(vals[1]);
  4. // if this is in a loop, you could now add them to the total hours/mins:
  5. totalHours += hours;
  6. totalMins += mins;
  7. // validate outside the loop
  8. if (totalHours > 7) // error
  9. if ((totalHours == 7) && (totalMins > 36)) // error here too.
  10.  
Feb 14 '08 #4
viki1967
263 Contributor
Sorry Acoder... but how to integrate your code with code existing ?
Many Thanks....
Feb 14 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
Where are you making the validation? In updateTime()?
Feb 14 '08 #6
viki1967
263 Contributor
Yes Acoder in UpdateTime()
Feb 14 '08 #7
acoder
16,027 Recognized Expert Moderator MVP
Just as you've used a loop in there, loop over the form elements in a similar manner:
Expand|Select|Wrap|Line Numbers
  1. var totalHours = 0;
  2. var totalMins = 0;
  3. for ( var n = 0 ; n < elems.length ; n++ )
  4.   {
  5.      if (elems[n].type == "text" && elems[n].value.match(re))
  6.         {
  7.            var vals = elems[n].value.split(":");
  8.            var hours = parseInt(vals[0]);
  9.            var mins = parseInt(vals[1]);
  10.            totalHours += hours;
  11.            totalMins += mins;
  12.         }
  13.   }
  14. // validate outside the loop
  15. if (totalHours > 7) // error
  16. if ((totalHours == 7) && (totalMins > 36)) // error here too.
  17.  
Feb 14 '08 #8
viki1967
263 Contributor
Sorry Acoder, but not working....

[php]
function updateTime(txtO bj)
{
if (window.opener == null) return;


var re = /^([01]\d|2[0-3]):[0-5]\d$/;


if (txtObj.value.l ength >= 5 && !txtObj.value.m atch(re))
{
alert("Inserire l'orario nel formato 'hh:mm'.");
txtObj.focus();
}


var frmObj = txtObj.form;
var elems = frmObj.elements ;


var result = "";
var destObj = window.opener.d ocument.myform. impiego;


if (frmObj.IRE.val ue.match(re))

var totalHours = 0;
var totalMins = 0;

{
for ( var n = 0 ; n < elems.length ; n++ )
{


if (elems[n].type == "text" && elems[n].value.match(re ))


{
var vals = elems[n].value.split(": ");
var hours = parseInt(vals[0]);
var mins = parseInt(vals[1]);
totalHours += hours;
totalMins += mins;
}

{
if (result.length) result += ";";

result += elems[n].name + "-" + elems[n].value;
}
}

destObj.value= result;
}
else destObj.value= "--:--";

// validate outside the loop
if (totalHours > 7) // error
if ((totalHours == 7) && (totalMins > 36)) // error here too.

}
[/php]
Feb 15 '08 #9
acoder
16,027 Recognized Expert Moderator MVP
There are two problems: one is that you want to validate before you calculate the result. So make two loops. The second problem is that where I've added comments, e.g. // error, you need to replace that with an error message.
Feb 15 '08 #10

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

Similar topics

1
4668
by: Beringer | last post by:
Hello, I am creating a custom schedule control similar to the way Outlook behaves. I am having some difficulty trying to graphically/visually resolve conflicting appointments on a schedule. Anyone have some ideas or a pointer or two to help me out? Thanks,
0
1956
by: cyshao | last post by:
Hi, My Friends: I have a program and I want to let machine automaticly auto it by using Windows task schedule. Sure, I can manually Create/Modify task in Windows task schedule. But I also hope to Create/Modify tasks by programming, for another program want to generate many tasks. Could you tell how to control windows task schedule by programming ? Thanks
1
2790
by: greg7224 | last post by:
I am currently working on a C# project that uses the Janus schedule controls, and am having trouble getting it to print correctly in Day view. The problem is that it will not print out the owners of the appointments unless I set the ShowAllDayArea parameter to true. When I do this, a large and unsightly grey box is drawn above the actual schedule in day view, wasting space and making things look generally ugly. I am using the built in...
15
10949
by: Tinus | last post by:
Hello all, I've created a custom control that draws a monthly schedule (using the Draw function in C#). Basically it draws 31 boxes and writes the day number in every box. This works great. But I now want to show a different tooltip for every day. For now I found out that I can add a tooltip for the entire custom control
1
1351
by: Danny Ni | last post by:
Hi, I have one user control named Schedule.ascx, I want to create another control which is quite similar to schedule.ascx but differs in some methods and some UI elements, the way I am doing it right now, I save schedule.ascx as another name, say schedule2.ascx then I go to code behind and chane the class name and the methods I like to change. Also modify the UI on ascx file. This is working. But there is a problem, evertime I change...
0
1098
by: Patrick | last post by:
I am using VB to implement a code behind class for an ASP.NET form. I am loading a DataGrid web server control with data from a table in a SQL database. the code is as follows: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here If Not Page.IsPostBack Then Dim con As SqlConnection = New SqlConnection
2
2256
by: John | last post by:
Hello everyone, I'm currently writing a program to keep track of schedule changes at a school. The goal is to have someone using the program to declare changes, then the program writes a html file, which is uploaded to a webserver. Then students and teachers can view it online, but there are also a couple of computers with 19" monitors standing around the school to display the webpage (IE kiosk mode). The program has a form containing...
4
1670
by: Yoram Biberman | last post by:
I have a few questions concerning concurrency control. I shall thank whoever can help me. Question #1 ========= Assume the following (concurrent) schedule, in which both transactions run in a serializable isolation level: T1 begin T2 begin T1 modifies an item A
1
1305
by: Prakash | last post by:
Hi Friends, I am developing scheduler application using C#. For displaying all schedule information i am using ListView control. Based on the status of the schedule, i have displayed the schedule information in the list view as seperate colors. I have faced the problem with deselecting the list view item. For example, if i select the first row,(with blue color) of the list view and deactivate the selected item by clicking the row...
0
9711
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9591
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10087
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.