zoukankan      html  css  js  c++  java
  • 夺命雷公狗---Smarty NO:19 html_options函数

    功能:把数组转化为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’);
  • 相关阅读:
    Reverse Integer
    First Bad Version
    Heaters
    Number of Segments in a String
    RPI学习--环境搭建_串口连接
    关键字const
    main函数参数的使用
    Redis 简单使用 and 连接池(python)
    南宁AI项目
    Go part 1 初探
  • 原文地址:https://www.cnblogs.com/leigood/p/5033422.html
Copyright © 2011-2022 走看看