Welcome Guest Search | Active Topics | Sign In | Register

Get year value of EO Date Picker by using JavaScript Options
Kusno
Posted: Tuesday, November 13, 2007 1:35:36 AM
Rank: Member
Groups: Member

Joined: 10/9/2007
Posts: 15
Dear Admin,

How do I get year value by using JavaScript ?.
I want to set my label control with year value that I choose from DatePicker.

In my EO DatePicker, I set ClientSetOnSelect to "SetForYear".

<script language="javascript" type="text/javascript">
function SetForYear()
{
var LbYear = document.getElementById("LbYear");
LbYear.innerHTML = "";

var DTPeriodFrom = eo_GetObject("DTPeriodFrom").getSelectedDate();
if (DTPeriodFrom != null)
{
// LbYear.innerHTML = DTPeriodFrom.Year();
alert(DTPeriodFrom.year());
}
}
</script>

and one more thing.

I have 2 DatePickerControl, example : DT1 and DT2.
Every time I choose DT1 date, I want to use JavaScript to add 7 days from DT1 date to DT2

Thanks,

Kusno


eo_support
Posted: Tuesday, November 13, 2007 4:41:55 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

getSelectedDate return a JavaScript Date object. You can find a list of functions the Date object supports at here:

http://www.w3schools.com/js/js_obj_date.asp

That should also answer your second question.

Thanks
Kusno
Posted: Tuesday, November 13, 2007 8:13:57 PM
Rank: Member
Groups: Member

Joined: 10/9/2007
Posts: 15
Dear EO_Support,

Thanks for you info.

function SetForYear()
{
var LbYear = document.getElementById("LbYear");
LbYear.innerHTML = "";

var DTPeriodFrom = eo_GetObject("DTPeriodFrom").getSelectedDate();
var DTPeriodTo = eo_GetObject("DTPeriodTo").getSelectedDate();
if (DTPeriodFrom != null)
{
LbYear.innerHTML = DTPeriodFrom.getYear();
var d = DTPeriodFrom.getDate();
var m = DTPeriodFrom.getMonth();
var y = DTPeriodFrom.getYear();
DTPeriodTo.setFullYear(y,m,d);
alert(DTPeriodTo);
}
}

But, I still have 2 questions :
1. If user change DTPeriodFrom date manually from its Textbox, LbYear does not change.

2. Why the value of DTPeriodTo does not change in the Form DTPeriodTo Textbox ? It's still old value, where as in MessageBox, I get a new value

Thanks,

Kusno
eo_support
Posted: Tuesday, November 13, 2007 9:32:55 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

I can not answer your first question because I do not know when SetForYear is called.

As for the second question, what you observed is the correct behavior. Our DatePicker DTPeriodTo and your local variable DTPeriodTo are totally different things. So changing your DTPeriodTo will not change our controls' value. You will need to call setSelectedValue on our object to change its value.

Thanks
Kusno
Posted: Tuesday, November 13, 2007 10:34:27 PM
Rank: Member
Groups: Member

Joined: 10/9/2007
Posts: 15
eo_support wrote:

I can not answer your first question because I do not know when SetForYear is called.

I set SetForYear in EO DatePicker property, ClientSetOnSelect .



eo_support wrote:

As for the second question, what you observed is the correct behavior. Our DatePicker DTPeriodTo and your local variable DTPeriodTo are totally different things. So changing your DTPeriodTo will not change our controls' value. You will need to call setSelectedValue on our object to change its value.

You're right, that was my mistake. I assign value to Variable not to DatePicker. Sorry...

But, I have tried this one :

eo_GetObject("DTPeriodTo").setSelectedValue = eo_GetObject("DTPeriodFrom").getSelectedDate();
alert(eo_GetObject("DTPeriodTo").getSelectedDate());

But still not work...

Thanks,
eo_support
Posted: Tuesday, November 13, 2007 10:52:53 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Kusno wrote:

I set SetForYear in EO DatePicker property, ClientSetOnSelect .


This is by design. ClientSideOnSelect is only called when you click your mouse button in the picker drop down. It is not fired when you actually type a date in. We are planing to have a new ClientSideOnChange property in our next release, that way keyboard input will also be taken care of.

Kusno wrote:

But, I have tried this one :

eo_GetObject("DTPeriodTo").setSelectedValue = eo_GetObject("DTPeriodFrom").getSelectedDate();
alert(eo_GetObject("DTPeriodTo").getSelectedDate());

But still not work...


Please refer to the client side API reference for this one. You are just pulling things out of your head and expect it would just magically work.
Kusno
Posted: Wednesday, November 14, 2007 5:44:28 PM
Rank: Member
Groups: Member

Joined: 10/9/2007
Posts: 15
Dear EO_Support,

Thanks for you support. I have found what I wanted by following your instruction. Please accept my apology for what I had written that might not appropriate to you.

Thanks.

function SetForYear()
{
var LbYear = document.getElementById("LbYear");
LbYear.innerHTML = "";

var DTPeriodFrom = eo_GetObject("DTPeriodFrom").getSelectedDate();
var DTPeriodTo = eo_GetObject("DTPeriodTo").getSelectedDate();
if (DTPeriodFrom != null)
{
LbYear.innerHTML = DTPeriodFrom.getYear();
eo_GetObject("DTPeriodTo").setSelectedDate(eo_GetObject("DTPeriodFrom").getSelectedDate());
}
}
eo_support
Posted: Wednesday, November 14, 2007 5:57:09 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Good job! Glad that you got it working!

There is nothing about "not appropriate". While we strive to provide the best support in the industry, we do expect our users to take some effort to troubleshoot before turning to us. It would be totally unrealistic for all of our users to rely on us to find all the code errors for them. We will do our best to give you pointers as to where to look for issues related to our product. But that's by no mean implies that we would help you troubleshoot every code error.

And thanks for sharing the code in the forum. We are sure it will be useful for other users!
Arbuz
Posted: Wednesday, July 23, 2008 11:31:00 PM
Rank: Member
Groups: Member

Joined: 7/23/2008
Posts: 12
Quote:

... ClientSideOnSelect is only called when you click your mouse button in the picker drop down. It is not fired when you actually type a date in. We are planing to have a new ClientSideOnChange property in our next release, that way keyboard input will also be taken care of.


How the new property specified above refers to?



eo_support
Posted: Thursday, July 24, 2008 3:14:31 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

For some reason this property has not been implemented. We will look into it and get back to you as soon as possible.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.