View previous topic :: View next topic |
Author |
Message |
gunnar
Joined: 25 Oct 2005 Posts: 6
|
Posted: Wed Oct 26, 2005 4:03 pm Post subject: Track buttons on page "<" and ">" without opening the popup. |
|
|
In addition to the PopCalendar I would like to add track buttons on the page. When you push the "<" the date should be changed to the previous month (in the format YYYY-MM) without showing the popup. The buttons should work similarto the ones on the popup but they should not display the popup and should change the "input" object right away and submit the form.
The idea here is to give the user the ability to traverse to the previous month with just one mouse click.
|
|
Back to top |
|
|
calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Wed Oct 26, 2005 6:39 pm Post subject: |
|
|
The following code should do the job:
Code: | <form name="testForm">
<input name="testfield">
<input type="button" value="<" onclick="prev(document.testForm.testfield)">
<input type="button" value=">" onclick="next(document.testForm.testfield)">
</form>
<script>
function parseMonth(f) {
var dt=f.value.match(/^(\d{4})-([0]?[1-9]|1[0-2])$/);
if (dt==null) {
var d=new Date();
return [d.getFullYear(), d.getMonth()+1];
}
return [parseInt(dt[1],10), parseInt(dt[2],10)];
}
function prev(f) {
var mth=parseMonth(f);
mth[1]--;
if (mth[1]<1) {mth[0]--; mth[1]=12}
f.value=mth[0]+"-"+padZero(mth[1]);
}
function next(f) {
var mth=parseMonth(f);
mth[1]++;
if (mth[1]>12) {mth[0]++; mth[1]=1}
f.value=mth[0]+"-"+padZero(mth[1]);
}
function padZero(n) {
return n<10?"0"+n:n;
}
</script> |
_________________ Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved. |
|
Back to top |
|
|
gunnar
Joined: 25 Oct 2005 Posts: 6
|
Posted: Thu Oct 27, 2005 9:35 am Post subject: |
|
|
Would it be possible to have the steps depend on what has been chosen (month, date, week). To have it depend on the format of the string ?
Month: Letīs say October 2005 has been chosen and the string is "2005-01" would it be possible to have "<" change the string to "2004-12" and ">" change the string to "2005-02".
Date: Letīs say "2005-10-09" has been chosen, would it be possible to have "<" change the string to "2005-10-08" and ">" change the string to "2005-10-10"
Week: Letīs say week 42 of 2005 has been chosen and the string is "2005-10-17 2005-10-23" would it be possible to have "<" change the string to "2005-10-10 2005-10-16" and ">" change the string to "2005-10-24 2005-10-30"
|
|
Back to top |
|
|
calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Fri Oct 28, 2005 12:05 am Post subject: |
|
|
Sorry, but that's not supported.
_________________ Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved. |
|
Back to top |
|
|
|