Example of a simple method for generating form elements in Smarty form
This example describes how to generate a simple form element by using Smarty. We will share this with you for your reference. The details are as follows:
The implementation principle of the form element generation function of smarty is: to generate and display menus or options for smarty, and to pass the value of an option for matching by default:
Example:
Php file: index. php
<? Php include ("smarty_inc.php"); $ smarty-> assign ('cust _ id', array (,); $ smarty-> assign ('cust _ names ', array ('ding qing', 'lei Lei ', 'ludong', 'song Zijian '); $ smarty-> assign ('customer _ id', 1003 ); $ smarty-> display ("index.html");?>
Template File: index.html
<select name=customer_id onkeypress=""><{html_options values=$cust_ids selected=$customer_id output=$cust_names}></select>
PS: We recommend several formatting, beautification, and conversion tools on this site to help you sort out messy code. I believe you can use them in future development:
Php code online formatting and beautification tools:
Http://tools.jb51.net/code/phpformat
JavaScript code beautification/compression/formatting/encryption tools:
Http://tools.jb51.net/code/jscompress
Online XML formatting/compression tools:
Http://tools.jb51.net/code/xmlformat
JSON code formatting and beautification tools:
Http://tools.jb51.net/code/json
Online XML/JSON conversion tools:
Http://tools.jb51.net/code/xmljson
Json code online formatting/beautification/compression/editing/conversion tools:
Http://tools.jb51.net/code/jsoncodeformat
SQL code online formatting and beautification tools:
Http://tools.jb51.net/code/sqlcodeformat