Home  >  Article  >  Backend Development  >  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
WBOYOriginal
2016-08-04 09:20:041472browse

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>

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>

This is my template
I want to make

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

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

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