Previous Page
Next Page

Tripod >> 3pod Tips & Learning and manuals for educations

Recipe 13.16. Retrieving Date Values

Problem

You want to retrieve a date from a date form control.

Solution

If you are using a date chooser or date field, use the instance's selectedDate property. Otherwise, use the FormController component to handle your form processing.

Discussion

The date chooser and date field components both have a selectedDate property that returns the date that the user has selected. The value that the property returns in either case is in the format of an ActionScript Date object. In most cases, you will want to retrieve the selected date only after users have indicated that they want to process the form data. Typically, that is done by clicking a submit button. The following code shows an example in which the selected date from a date chooser named cdcCalendar is retrieved and displayed when the user clicks a button:

	var oListener:Object = new Object();
	oListener.click = function(oEvent:Object):Void {
	  trace(cdcCalendar.selectedDate);
	};
	cbtSubmit.addEventListener("click", oListener);

If you are not using a date field or a date chooser, but rather a text input or input text field, you can simply retrieve the information the user has input via the text property as discussed in Recipe 13.11. However, as was mentioned in Recipe 13.9, verifying that the information represents a valid date requires some advanced ActionScript code. Therefore, unless you are very familiar with ActionScript, you will likely find it much simpler to use a FormController component to manage your form.

See also

Recipe 13.9, Recipe 13.17

Tripod >> 3pod Botom Tips & Learning and manuals for educations

Previous Page
Next Page

 

bluedot bluedots greydots pinkdots

Tripod >> 3pod Tips & Learning and manuals for educations