Welcome Guest, Not a member yet? Register   Sign In
Repopulate a Dropdown
#7

[eluser]bsauls[/eluser]
This works for me with 2.02 and automatic form validation via config file.
Code is from the view within form, form fieldset:
Code:
<?php $current_year = date("Y");
$next_year = strtotime ( '+1 year' , strtotime (date("Y") ) );
$next_year = date("Y", $next_year);
$options = array(
  $current_year  => $current_year,
  $next_year    => $next_year,
  );?>
<label for="year" style="width:176px">Application Period beginning in:</label>
<select name="year" id="year" style="width:56px" tabindex="20" >
&lt;?php echo '<option value="'.$current_year.'" '.set_select('year',$current_year, set_value('year'==$current_year)).'>'.$current_year.'</option>'?&gt;
&lt;?php echo '<option value="'.$next_year.'" '.set_select('year',$next_year, set_value('year'==$next_year)).'>'.$next_year.'</option>'?&gt;
If set_value('year'==$next_year) is true, it generates selected="selected" in the HTML for that option. I hope this helps someone.


Messages In This Thread
Repopulate a Dropdown - by El Forum - 06-08-2010, 08:54 AM
Repopulate a Dropdown - by El Forum - 06-08-2010, 10:17 AM
Repopulate a Dropdown - by El Forum - 06-08-2010, 10:31 AM
Repopulate a Dropdown - by El Forum - 06-08-2010, 10:48 AM
Repopulate a Dropdown - by El Forum - 06-08-2010, 11:39 AM
Repopulate a Dropdown - by El Forum - 02-08-2011, 07:47 PM
Repopulate a Dropdown - by El Forum - 06-20-2011, 04:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB