CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Setting date based on Priority

Print topic Send  topic

Author Message
robn

Posts: 70
Posted: 12/19/2005, 10:52 AM

Hi

I'm having trouble setting the date of a text field based on the priority of a record. What I am after doing is setting a date in the future depending of the priority (so if priority is set to high target date is in 1 days time, if medium 7 days time and if low the target date is 28 days time). These dates are based of when the record was logged.

I've tried writing some Java (on the OnChange Event) with no success and was wondering if this is the easiest way to do it or is there a better way. To give you an idea the kind of code I have tried looks like this.

function SetTargetDate(){  
if (document.tblQualcall.priority.value == 1) {      
      
        document.tblQualcall.Targetdate.value = document.tblQualcall.datein.value+ (1);  
}      
else if (document.tblQualcall.priority.value == 2) {      
        document.tblQualcall.Targetdate.value = document.tblQualcall.datein.value + (7);     
                }    
else if (document.tblQualcall.priority.value == 3) {      
        document.tblQualcall.Targetdate.value = document.tblQualcall.datein.value + (30);     
                }    
}

but all this does is add 1, 7 or 30 after the date. Is there a simple solution to this issue?

any help would be greatly appreciated.

many thanks

Rob
View profile  Send private message
matheus

Posts: 386
Posted: 12/19/2005, 11:38 AM

Must use javascript because priority is a listbox (something like this), right?

Your function to add qt of days in some date.

  
function getDate(){  
	date = new Date();  
	alert(date);  
	date = new Date(date.getFullYear(), date.getMonth(), date.getDate()+5);  
	alert(date);  
        date = new Date(date.getFullYear()+3, date.getMonth()-1, date.getDate()+20);  
        alert(date);  
}  

Just need discover how get text value and return Date. I assume that need look Datepicker.js, must had a ParseDate, something like this.
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
matheus

Posts: 386
Posted: 12/19/2005, 11:40 AM

And remembering that all value used in javascript it's assumed was String. Must cast type. If get a number from input, in javascript came like string. Because this it add 1, 7 and 30 at the end.
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
robn

Posts: 70
Posted: 12/20/2005, 3:10 AM

Matheus Thanks once again for you help

I've now managed to get a date into the text field based on the code you kindly provided. But the problem I now have is formating the style. The code looks like this
function SetTargetDate(){  
date =  new Date;   
if (document.tblQualcall.priority.value == 2) {      
      
        document.tblQualcall.Targetdate.value = new Date(date.getYear(), date.getMonth(), date.getDate()+1);   
}      
else if (document.tblQualcall.priority.value == 1) {      
        document.tblQualcall.Targetdate.value = new Date(date.getYear(), date.getMonth(), date.getDate()+7);    
                }    
}

I've tried to use the SimpleDateFormat code but can't find a way to get this into the statement. I'm looking to produce a "dd mmm YYYY" format where as at the moment the format looks like this "Tue Dec 27 00:00:00 UTC 2005" which I presume is the New Date default format. Any help on how I may change the format would be greatly appreciated.

thanks again

Rob
View profile  Send private message
matheus

Posts: 386
Posted: 12/20/2005, 9:03 AM

Hi robn,

Must use the code:
  
formatDate(date, parseDateFormat("dd mmm YYYY"));  

In your case, if you had a datepicker, can get format from his variable. Like this (code generated by CCS, when use Datepicker):

  
var form_DatePicker_dt_field = new Object();   
form_DatePicker_dt_field.format           = "dd/mm/yyyy";  
form_DatePicker_dt_field.style            = "Styles/Basic/Style.css";  
form_DatePicker_dt_field.relativePathPart = "../../";  
form_DatePicker_dt_field.themeVersion = "3.0";  

Then to get format use something like:
  
document.tblQualcall.Targetdate.value = formatDate(new Date(date.getYear(), date.getMonth(), date.getDate()+1), parseDateFormat("dd mmm YYYY"));  
  
or   
  
document.tblQualcall.Targetdate.value = formatDate(new Date(date.getYear(), date.getMonth(), date.getDate()+1), parseDateFormat(form_DatePicker_dt_field.format));  

Code doesn't tested.
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
robn

Posts: 70
Posted: 01/06/2006, 9:03 AM

matheus

Many thanks once again for your help your solution worked great

thanks again

Rob


View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.