ホームページ制作会社、サイト制作、その他各種システムの構築、CGI、PHP等のWEBアプリ開発

ホームページ制作・システム構築・DB設計ホームページ制作・システム構築・DB設計
ホームページ制作とWEBシステムの構築、カスタマイズから運用サポートまで。
スペーサー

smartyのフォームselectでループしながら本日の日付にselectedする方法。


に関連する記事です。 これは自分への覚書です。
問い合わせフォームなどで本日の日付をselectedするサンプルです。


phpファイル
$year = date('Y');
$month = date('n');
$day = date('j');

$smarty->assign('year', $year);
$smarty->assign('month', $month);
$smarty->assign('day', $day);


テンプレートファイル
<select name="year">
<option value="">選択</option>
<{section name="sel_year" start=2011 loop=2020}>
<option value="<{$smarty.section.sel_year.index|escape}>"<{if $year == $smarty.section.sel_year.index}> selected="selected"<{/if}>><{$smarty.section.sel_year.index|escape}></option>
<{/section}>
</select>年

<select name="month">
<option value="">選択</option>
<{section name="sel_month" start=1 loop=13}>
<option value="<{$smarty.section.sel_month.index|escape}>"<{if $month == $smarty.section.sel_month.index}> selected="selected"<{/if}>><{$smarty.section.sel_month.index|escape}></option>
<{/section}>
</select>月

<select name="day">
<option value="">選択</option>
<{section name="sel_day" start=1 loop=32}>
<option value="<{$smarty.section.sel_day.index|escape}>"<{if $day == $smarty.section.sel_day.index}> selected="selected"<{/if}>><{$smarty.section.sel_day.index|escape}></option>
<{/section}>
</select>日

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
ホームページ制作・システム構築・DB設計
●ユタデザイン
●住所:〒135-0062
東京都江東区東雲2-7-5-2105
ユタデザイン
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+



Valid XHTML 1.0 Transitional スペーサー 正当なCSSです!