1
jilong
how to autofill the age?
  • 2007/7/20 8:04

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


I try hack on edituser.php to make the age field be autofill in when after keyin the year of birth. i think i almost there but just can't get the 'year of birth' value,

1. I have replicate the formtext.php change it to formyear.php
Here is the code i change on my formyear.php:

Class and Function already change to 'XoopsFormYear' and
le="color: #000000"><?php function render(){ $year = date("Y"); $year2 = "1980"; $year3 = $year-$year2; return "<input type='text' name='".$this->getName()."' id='".$this->getName()."' size='".$this->getSize()."' maxlength='".$this->getMaxlength()."' value='".$year3."'".$this->getExtra()." />"; }


2. Add 'include_once XOOPS_ROOT_PATH."/class/xoopsform/formyear.php";' into xoopsformloader.php

3. On edituser.php i add in this code:

le="color: #000000"><?php $year_text = new XoopsFormText(_US_YEAR, 'year', 4, 4, $xoopsUser->getVar('year', 'E')); $age_text = new XoopsFormYear(_US_AGE, 'age', 4, 4, $xoopsUser->getVar('age', 'E'));


I set the $year2 =1998 and the result i get is 27. ^^
But how can i replace the 1998 to the year value i had enter?

you guy have any ideal to do this?

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits