ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 16th, 2003, 02:27 AM
thehen thehen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 thehen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Automatically update date and time

I am trying to do the following

1. I have a Severity dropdown (1, 2, 3, 4 and 5) in my script
2. Date (dateref)(varchar)
3. time (timeref) (varchar)

I want to do this, but have no clue how to write the script to do it.

It must Automatically update date and time as per severity rating

a. Severity 1. Date to be same day, Time + 1hour
b. Severity 2. Date +1 day. Time to be current time
c. Severity 3. Date + 3 days. Time to be current time
d. Severity 4. Date + 5 days. Time to be current time
e Severity 5. Date and time to default blank.

If I select any severity, it must changed the time and date that is on the same form, and save it to the table.

Hope any one can help me

Reply With Quote
  #2  
Old October 16th, 2003, 07:38 AM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I just finished a function today (javascript required to update client side form) that works in much the same way.

I'll try and remember to post it here tomorrow
__________________
How can I soar like an eagle when
I'm flying with turkey's?

Reply With Quote
  #3  
Old October 16th, 2003, 08:32 PM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Well here it is , others will probably scoff at the coding, but hey, it works.
PHP Code:
<script type="text/javascript">
function 
lastday()
{
   
/* This function updates the end date of a promotion based
    * on the period entered for promotion length
    */
   
var runsfor,rExp;
   var 
dmy;

   
// get the week commencing date and break into an array
   
commarr document.forms["PromAdd1"].WeekComm.value.split("/");

   
// get the length of time the promotion runs
   
runsfor document.forms["PromAdd1"].PromLength.value;

   
// get the d, m, y for the date from the array
   
= new Number(commarr[0]);
   
= new Number(commarr[1]) - 1;  // must take of one as months stored as 0-11
   
= new Number(commarr[2]);
   
// if a two digit year was entered, turn it to 2000
   
if (2000)
   {
      
2000;
   }

   
// create a new date based on original entered data
   
comm = new Date(y,m,d,00,00,00);    

   var 
slocfactorends;
   
// use a regular expression to search for white space
   // string e.g. "2 weeks"
   
rexp = /s/;
   
sloc runsfor.search(rexp);

   
// get the period length as a number
   
factor = new Number(runsfor.slice(0,sloc));

   
//86400000 milliseconds in a day
   
   // use a regular expression to determine weeks or months
   
rExp = /week/i;
   var 
nend = new Date();
   
// check for weeks
   
if(runsfor.search(rExp)>-1)
   {
      
// use the milliseconds since property, and add accordingly
      
ends = (comm.valueOf() - 86400000 + (factor * (86400000 7)));
      
nend.setTime(ends);

      
// set the end value on the form based on the calculation
      
document.forms["PromAdd1"].PromEnds.value nend.getDate() + '/' + (nend.getMonth() + 1) + '/' nend.getFullYear();
   }

   
// check for the month.
   
rExp = /month/i;
   if(
runsfor.search(rExp)>-1)
   {
      
ends = (comm.valueOf());
      
nend.setTime(ends);
      
nend.setMonth(nend.getMonth() + factor);
      
ends = (nend.valueOf() - 86400000);
      
nend.setTime(ends);
      
document.forms["PromAdd1"].PromEnds.value nend.getDate() + '/' + (nend.getMonth() + 1) + '/' nend.getFullYear();
   }
}
</script> 


Let me know if you have any queries.

HTH

Reply With Quote
  #4  
Old October 18th, 2003, 09:41 PM
thehen thehen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 thehen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
help

Still waiting to see if someone can realy help me with this problem

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Automatically update date and time


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT