Smarty简单生成表单元素的方法示例_php教程-查字典教程网
Smarty简单生成表单元素的方法示例
Smarty简单生成表单元素的方法示例
发布时间:2016-12-29 来源:查字典编辑
摘要:本文实例讲述了Smarty简单生成表单元素的方法。分享给大家供大家参考,具体如下:smarty生成表单元素功能实现的原理是:给smarty一...

本文实例讲述了Smarty简单生成表单元素的方法。分享给大家供大家参考,具体如下:

smarty生成表单元素功能实现的原理是:给smarty一个数组,用于生成和显示菜单或选项,另外在传递一个选项的值,用于默认选择的匹配:

示例如下:

php文件:index.php

<"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 }>

PS:这里推荐几款本站的格式化/美化/转换工具可以帮助你整理杂乱无章的代码,相信大家在以后的开发中能够用得上:

php代码在线格式化美化工具:

http://tools.jb51.net/code/phpformat

JavaScript代码美化/压缩/格式化/加密工具:

http://tools.jb51.net/code/jscompress

在线XML格式化/压缩工具:

http://tools.jb51.net/code/xmlformat

JSON代码格式化美化工具:

http://tools.jb51.net/code/json

在线XML/JSON互相转换工具:

http://tools.jb51.net/code/xmljson

json代码在线格式化/美化/压缩/编辑/转换工具:

http://tools.jb51.net/code/jsoncodeformat

sql代码在线格式化美化工具:

http://tools.jb51.net/code/sqlcodeformat

希望本文所述对大家基于smarty模板的PHP程序设计有所帮助。

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新php教程学习
    热门php教程学习
    编程开发子分类