How to use thinkPHP's Html template tags

不言
Release: 2023-03-30 09:40:01
Original
3044 people have browsed it

This article mainly introduces how to use Html template tags in thinkPHP. It has a certain reference value. Now I share it with you. Friends in need can refer to it

If we need a select drop-down menu now item, then we can do this in ThinkPHP

Note: Before using tags such as , you must introduce the TP tag library:
If we need a select drop-down menu item now, we can do this in ThinkPHP.

1. Obtain data in the method of the Action controller, for example:

##Copy code The code is as follows:

public function mylist(){ 
$user = new Model(‘User'); 
$list = $user->getField(‘id,username'); 
$this->assign(‘users',$list); 
$this->display(); 
}
Copy after login

2. Import the tag library into the template page and write the following code

##Copy code

The code is as follows:

<tagLib name="html" /> 
<html:select name="uid" options="users" first="请选择用户" change="alert(‘Hello&#39;)"/>
Copy after login
In this way, we only use a simple tag to achieve the following functions: (Compiled HTML code)


##Copy code

The code is as follows:

<select id="" name="uid" onchange="alert(‘Hello&#39;)" ondblclick="" class=""> 
<option value="">请选择用户</option> 
<option value="1″>no1</option> 
<option value="2″>no2</option> 
<option value="3″>no3</option> 
<option value="4″>no4</option> 
</select>
Copy after login
Related recommendations:

ThinkPHP template judgment output Empty tag usage


Use thinkphp’s own method to generate static html files

The above is the detailed content of How to use thinkPHP's Html template tags. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!