Smarty如何產生簡單的表單元素

來源:互聯網
上載者:User
本文主要介紹了Smarty簡單產生表單元素的方法,涉及Smarty模板檔案操作的相關技巧,需要的朋友可以參考下。希望對大家有所協助。

具體如下:

smarty產生表單元素功能實現的原理是:給smarty一個數組,用於產生和顯示菜單或選項,另外在傳遞一個選項的值,用於預設選擇的匹配:

樣本如下:

php檔案:index.php

<?php include("smarty_inc.php");$smarty->assign('cust_ids',array(1000,1001,1002,1003));$smarty->assign('cust_names',array('丁慶','閆磊','呂東','宋子健'));$smarty->assign('customer_id',1003);$smarty->display("index.html");?>

模板檔案:index.html

<select name=customer_id onkeypress=""><{html_options values=$cust_ids selected=$customer_id output=$cust_names}></select><hr /><{html_radios name="id" values=$cust_ids selected=$customer_id output=$cust_names }>

相關推薦:

Smarty模板引擎視頻教學的資料課程推薦

php內建函數如何在smarty中調用的執行個體分享

php smarty模版操作符有哪些?操作符怎麼使用?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.