标签:
功能:把数组转化为option下拉选项
基本语法:
<select name=customer_id>
{html_options values=$cust_ids selected=$customer_id output=$cust_names}
</select>
参数说明:
output:要遍历输出的数组
values:每一个下拉选项的value值,要求是一个数组
selected:被选中的元素,要求也是一个数组
demo6.html示例代码:
<!DOCTYPE html> <html> <head> <meta charset=’utf-8′> <title></title> </head> <body> <select multiple=”multiple” name=”like”> {html_options output=$output values=$values selected=$checked} </select> </body> </html>
demo6.php示例代码:
<?php require “smarty/Smarty.class.php”; $smarty = new Smarty(); //output假如是从数据库中读取出来的数据 $output = array(‘php’,’apache’,’mysql’,’linux’); $values = array(1,2,3,4);//依次对应上面的值得 $checked = array(1,3); $smarty -> assign(‘output’,$output); $smarty -> assign(‘values’,$values); $smarty -> assign(‘checked’,$checked); $smarty -> display(‘demo6.html’);
夺命雷公狗---Smarty NO:19 html_options函数
标签:
原文地址:http://www.cnblogs.com/leigood/p/5033422.html