Home  >  Article  >  Backend Development  >  Smarty简单生成表单元素的方法示例,smarty表单_PHP教程

Smarty简单生成表单元素的方法示例,smarty表单_PHP教程

WBOY
WBOYOriginal
2016-07-12 08:50:44907browse

Smarty简单生成表单元素的方法示例,smarty表单

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

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

示例如下:

php文件:index.php

<&#63;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");
&#63;>

模板文件: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相关内容感兴趣的读者可查看本站专题:《smarty模板入门基础教程》、《PHP模板技术总结》、《PHP基于pdo操作数据库技巧总结》、《PHP运算与运算符用法总结》、《PHP网络编程技巧总结》、《PHP基本语法入门教程》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1133101.htmlTechArticleSmarty简单生成表单元素的方法示例,smarty表单 本文实例讲述了Smarty简单生成表单元素的方法。分享给大家供大家参考,具体如下: smarty生...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn