Home > Backend Development > PHP Tutorial > html - How can thinkphp drop-down menu select different drop-down menu items by default according to the parameters passed by assign?

html - How can thinkphp drop-down menu select different drop-down menu items by default according to the parameters passed by assign?

WBOY
Release: 2016-08-04 09:20:04
Original
1503 people have browsed it

html - How can thinkphp drop-down menu select different drop-down menu items by default according to the parameters passed by assign?
This is the data I passed from the background to the template

html - How can thinkphp drop-down menu select different drop-down menu items by default according to the parameters passed by assign?


<code><form action="{:U('Admin/Change/changegroup')}" method="post" accept-charset="utf-8">
                                <foreach name="data" item="v">
                                    <tr>
                                        <td align="center">
                                            <font>{++$i}</font>
                                        </td>
                                        <td align="center">
                                            <font>{$v.admin_name}</font>
                                        </td>
                                        <td width="25%">
                                            <select name="#" id="#" style="width: 300px;" class="span2">
                                                <option value="1">第一组</option>
                                                <option value="2">第二组</option>
                                                <option value="3">第三组</option>
                                                <option value="4">第四组</option>
                                                <option value="5">第五组</option>
                                            </select>
                                        </td>
                                        <td>
                                            <div style="text-align: center;">
                                                <a href="#">修改</a>
                                            </div>
                                        </td>
                                    </tr>
                                </foreach>
                            </form></code>
Copy after login
Copy after login

This is my template
I want to make

Reply content:

html - How can thinkphp drop-down menu select different drop-down menu items by default according to the parameters passed by assign?
This is the data I passed from the background to the template

html - How can thinkphp drop-down menu select different drop-down menu items by default according to the parameters passed by assign?


<code><form action="{:U('Admin/Change/changegroup')}" method="post" accept-charset="utf-8">
                                <foreach name="data" item="v">
                                    <tr>
                                        <td align="center">
                                            <font>{++$i}</font>
                                        </td>
                                        <td align="center">
                                            <font>{$v.admin_name}</font>
                                        </td>
                                        <td width="25%">
                                            <select name="#" id="#" style="width: 300px;" class="span2">
                                                <option value="1">第一组</option>
                                                <option value="2">第二组</option>
                                                <option value="3">第三组</option>
                                                <option value="4">第四组</option>
                                                <option value="5">第五组</option>
                                            </select>
                                        </td>
                                        <td>
                                            <div style="text-align: center;">
                                                <a href="#">修改</a>
                                            </div>
                                        </td>
                                    </tr>
                                </foreach>
                            </form></code>
Copy after login
Copy after login

This is my template
I want to make

<code><option value="1" <eq name="v.admin_team" value="1">selected</eq>>第一组</option></code>
Copy after login

To be honest, it is generally more convenient to use jquery to write this kind of thing. It should be difficult to use the template syntax of thinkphp alone

Use or in option to make conditional judgment, although it will be a bit cumbersome

That’s it

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