首页 > php框架 > smarty html_options 设置默认select 选值

smarty html_options 设置默认select 选值

smarty html_options 设置默认select 选值

index.php:

<?php
require('Smarty.php.class');
$smarty = new Smarty;
$smarty->assign('cust_options', array(
   1001 => 'Joe Schmoe',
   1002 => 'Jack Smith',
   1003 => 'Jane Johnson',
   1004 => 'Charlie Brown'));
$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');


index.tpl:

<select name=customer_id>
 {html_options options=$cust_options selected=$customer_id}
</select>


OUTPUT: (both examples)

<select name=customer_id>
 <option value="1000">Joe Schmoe</option>
 <option value="1001" selected="selected">Jack Smith</option>
 <option value="1002">Jane Johnson</option>
 <option value="1003">Charlie Brown</option>
</select>


本文地址:https://www.phprm.com/frame/smarty_html_options_selec.html

转载随意,但请附上文章地址:-)

标签:none

发表留言