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>
教程网址:http://www.phprm.com/frame/smarty_html_options_selec.html
欢迎收藏∩_∩但请保留本文链接。