1
sgshell
script needed for input birthday date in a custom make form of xoops
  • 2004/12/17 6:05

  • sgshell

  • Just popping in

  • Posts: 94

  • Since: 2004/10/4


hi,
I need to make a form that will need to input BIRTHDAY

Do anyone know any javascript or others that i could make a drop down selection for day,month,year... which could be use in XOOPS without problem?

Thks

2
Draven
Re: script needed for input birthday date in a custom make form of xoops
  • 2004/12/17 7:11

  • Draven

  • Module Developer

  • Posts: 337

  • Since: 2003/5/28


Well you have a few options. You can use the XOOPS date class for forms (XoopsFormTextDateSelect).

Or if you really want a javascript solution you can use webFX's date picker found at http://webfx.eae.net/dhtml/datepicker/datepicker.html

DEMO: http://webfx.eae.net/dhtml/datepicker/demo.html

3
sgshell
Re: script needed for input birthday date in a custom make form of xoops
  • 2004/12/17 14:57

  • sgshell

  • Just popping in

  • Posts: 94

  • Since: 2004/10/4


Hi, thks .... i see the site but i do not know how to modify and use the example they give....

could any one give example on how to do it in XOOPS data?


I saw this javascipt on date selecter it is small n nice:

dsInput.js

Quote:
/**
* Date Selector Input
*
* An intelligent set of 3 combo boxes for entering dates.
* The boxes update according to which day/month/year has been selected
* to account for days in each month (including leap years).
*
* @author Kevin Southworth
* @link http://kevin.tridubdesign.com
* @modified 2004-04-06
* @version 0.2
*/

/**
* The date selector constructor
*
* @access public
* @param string objName Name of the object that you create
* @param string formName Name of the form this object is in (OPTIONAL)
*/
function dsInput( objName, formName ) {

/* Properties */
this.objName = objName;
this.today = new Date();
this.date = this.today.getDate();
this.month = this.today.getMonth()+1;
this.year = this.today.getFullYear();
if(this.year < 2000) this.year += 1900; //for Netscape
this.yearComboRange = 5;
this.formName = arguments[1] ? arguments[1] : 'none';
this.dayObj = '';
this.monthObj = '';
this.yearObj = '';
this.monthNames = new Array( '','January','February','March','April','May','June','July','August','September','October','November','December' );


/* Public Methods */
this.setToToday = ds_setToToday;
this.adjustDaysInMonth = ds_adjustDaysInMonth;
this.setDate = ds_setDate;
this.setDateParts = ds_setDateParts;
this.getSelYear = ds_getYear;
this.getSelMonth = ds_getMonth;
this.getSelDay = ds_getDay;

/* Private Methods */
this._initOptions = ds_initOptions;
this._writeYearOptions = ds_writeYearOptions;
this._writeMonthOptions = ds_writeMonthOptions;
this._writeDayOptions = ds_writeDayOptions;
this._getDaysInMonth = ds_getDaysInMonth;

/* Constructor Code */
if( this.formName == 'none' ) {
this.dayObj = eval("document.forms[0]." + this.objName + "D");
this.monthObj = eval("document.forms[0]." + this.objName + "M");
this.yearObj = eval("document.forms[0]." + this.objName + "Y");
} else {
this.dayObj = eval("document." + this.formName + "." + this.objName + "D");
this.monthObj = eval("document." + this.formName + "." + this.objName + "M");
this.yearObj = eval("document." + this.formName + "." + this.objName + "Y");
}
this._initOptions();
this.setToToday();
this.adjustDaysInMonth();
}

/* Class Methods */

/**
* Set the date boxes to today's date
*/
function ds_setToToday() {
this.setDateParts( this.year, this.month, this.date );
}
/**
* Set the date boxes to specific date
* @param string dateStr 'YYYYMMDD'
*/
function ds_setDate( dateStr ) {
var y, m, d;
y = dateStr.substr(0,4);
m = dateStr.substr(4,2);
d = dateStr.substr(6,2);
this.setDateParts( y, m, d );
}
/**
* Set the date boxes to today's date
* @param integer year
* @param integer month
* @param integer day
*/
function ds_setDateParts( year, month, date ) {
this.dayObj[date-1].selected = true;
this.monthObj[month-1].selected = true;
for( i=0; i < this.yearObj.length; i++ ) {
if( this.yearObj[i].value == year )
this.yearObj[i].selected = true;
}
this.adjustDaysInMonth();
}


function ds_getYear() {
return this.yearObj[this.yearObj.selectedIndex].value;
}

function ds_getMonth() {
return this.monthObj[this.monthObj.selectedIndex].value;
}

function ds_getDay() {
return this.dayObj[this.dayObj.selectedIndex].value;;
}

/**
* Adjust the 'days' box according to the
* current month and year
*/
function ds_adjustDaysInMonth() {
Month = this.monthObj[this.monthObj.selectedIndex].value;
//alert( Month );
Year = this.yearObj[this.yearObj.selectedIndex].value;
//alert( Year);

DaysForThisSelection = this._getDaysInMonth(Month, Year);
PrevDaysInSelection = this.dayObj.length;

if (PrevDaysInSelection > DaysForThisSelection) {
for (i=0; i<(PrevDaysInSelection-DaysForThisSelection); i++) {
this.dayObj.options[this.dayObj.options.length - 1] = null
}
}
if (DaysForThisSelection > PrevDaysInSelection) {
var prevLastDay = this.dayObj.options.length;
for( i = prevLastDay+1; i <= DaysForThisSelection; i++ ) {
var newOption = new Option( i, i );
var optionsColl = this.dayObj.options;
optionsColl[optionsColl.length] = newOption;
}
}
if (this.dayObj.selectedIndex < 0)
this.dayObj.selectedIndex == 0;
}

/* Private Methods */

function ds_initOptions() {
this._writeYearOptions();
this._writeMonthOptions();
this._writeDayOptions();
}

function ds_getDaysInMonth( m, y ) {
monthdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (m != 2) {
return monthdays[m];
} else {
return ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0 ? 29 : 28);
}
}

function ds_writeYearOptions() {
for( i=(this.year-this.yearComboRange); i<=(this.year+this.yearComboRange); i++ ) {
var newOption = new Option( i, i );
var optionsColl = this.yearObj.options;
optionsColl[optionsColl.length] = newOption;
}
}

function ds_writeMonthOptions() {
for( i=1; i <= 12; i++ ) {
var newOption = new Option( this.monthNames[i], i );
var optionsColl = this.monthObj.options;
optionsColl[optionsColl.length] = newOption;
}
}

function ds_writeDayOptions() {
for( i=1; i <= 31; i++ ) {
var newOption = new Option( i, i );
var optionsColl = this.dayObj.options;
optionsColl[optionsColl.length] = newOption;
}
}



the html to use it:

Quote:
























It is nice but i can't get it to work with xoops...it work fine without xoops...but after i add in the main.php and header, footer of XOOPS ...it refuse to work and I do not know why...

i m noob in javascript, could any one help to see what happen? thks you

4
sgshell
Re: script needed for input birthday date in a custom make form of xoops
  • 2004/12/18 10:22

  • sgshell

  • Just popping in

  • Posts: 94

  • Since: 2004/10/4


any one help?

Login

Who's Online

345 user(s) are online (279 user(s) are browsing Support Forums)


Members: 0


Guests: 345


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits