Nitobi User Forums Forum Index

    (RSS)
Nitobi User Forums
Nitobi Support Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

multiple calendars and field names

 
Post new topic   Reply to topic    Nitobi User Forums Forum Index -> Calendar
View previous topic :: View next topic  
Author Message
rickoneil



Joined: 13 Jun 2008
Posts: 3

PostPosted: Fri Sep 05, 2008 5:25 am    Post subject: multiple calendars and field names Reply with quote

just got the product and it looks real promising, however, in many web applications, multiple dates and field names are standard and there is no example that I got that show this nicely.

more specifically, the way to handle this would be to have an event handler that could acceept the field name as well as the 'this' calendar object, this way the event handler could handle multiple field names....

but i'm a cold fusion programmer, not a javascript guy. thats why I buy extensions, supposed to be faster.....

so using the calendar example index.html page as an example, can anyopne assist in the folowing.

Heres the handler as written in the sample:

Code:
function populateDateField(calendar)
{
   var date = calendar.getDate().toString();
   document.getElementById('dateField').value = date.substring(0, date.indexOf("00:00:00"));
   $('calendarContainer').style.visibility = "hidden";
}


and the calling

Code:
<div>
<div style="border:1px solid #9ABFF5;width:200px;height:25px;float:left;">
<input id="dateField" type="text" style="border:0px;padding-left:4px;padding-top:2px;"/>
</div>
<img src="cal.gif" style="float:left;margin-left:5px;" onClick="toggleCalendar()"/>
<div id="calendarContainer" style="visibility:hidden;clear:both;">
<ntb:datepicker id="cal1" onsetdate="populateDateField(this)" timepickerenabled="false" theme="base" ></ntb:datepicker>
</div>
</div>


In the last bit if the code the line we see
Code:

 onsetdate="populateDateField(this)"


I want to send the field name in this like this
Code:

 onsetdate="populateDateField(this, fieldname)"


and have the handler accept this string and assign it to
the line
Code:

document.getElementById(PassedArgument).value = date.substring(0, date.indexOf("00:00:00"));


any help on making this handler accept the passed fieldname??

thanks
Back to top
View user's profile Send private message
Fil_Nitobi
Site Admin


Joined: 18 Aug 2008
Posts: 30
Location: Nitobi Office

PostPosted: Fri Sep 05, 2008 8:17 pm    Post subject: Reply with quote

Hi rickoneil,

You could change the JavaScript function that extracts the date from the Calendar component and assigns it to a specified HTML element, just as you suggested:
Code:

function populateDateField(calendar,container)
{
   var date = calendar.getDate().toString();
   document.getElementById(container).value = date.substring(0, date.indexOf("00:00:00"));
   $('calendarContainer').style.visibility = "hidden";
}


Then, for each of your Calendar markups, you would assign some string value that specifies this HTML element as the second parameter to the function. For example, in one calendar you could have the onsetdate attribute set like this:
Code:

onsetdate="populateDateField(this, 'container1')"

... and in another you could have this:
Code:

onsetdate="populateDateField(this, 'container2')"

Please note that the second argument is a string that specifies the element ID, so you have to enclose it in single quotes.

Hope that helps,
Fil
Junior Web Software Engineer
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Nitobi User Forums Forum Index -> Calendar All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group