in my website i am using an elements array to define all my form elements in a config file. it's working fine now what i need is 2 Selectboxes that will be generated dynamically. first selectbox should contains month names from Jan-Dec an开发者_StackOverflow社区d second selectbox should contain years from current year to +10.
Please suggest how may i configure this situtation efficently?
thanks in advance.
$ELEMENTS["name"] = array("label"=>"Username", "type"=>"text", "name"=>"user_name", "width" => "50", "validationtype"=>"text");
$ELEMENTS["email"] = array("label"=>"E-Mail", "type"=>"text", "name"=>"e_mail", "width" => "50", "validationtype"=>"email");
$ELEMENTS["birthdate"] = array("label"=>"Date of birth", "type"=>"text", "name"=>"birth_date", "width" => "50", "validationtype"=>"datel");
I am not sure you can. Typically the example you gave are for generating a <INPUT ...>
tag and a selectbox is created by a <SELECT ...>
tag. In addition, this tag includes a list of options like this:
<select name="car">
<option value="volvo">Volvo</option>
<option value="saab" selected="1">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
Inputs are:
<input type="text" name="car" value="" width="50" />
For year you can use the following
for($i = date('Y') ; $i < date('Y') + 10 ; $i++)
$YEARS["name"] = $i ;
For month
for($i = 1 ; $i <=12 ; $i++)
$MONTHS = date('F',mktime(0,0,0,$i));
Hop this would help
精彩评论