samrty 對二維數組資訊不能全部顯示的處理

來源:互聯網
上載者:User
方法一:
{foreach  from="$information" item="foo" key="k"}
                    <tr>
                            <td>
                            <input type="radio" name="son_id{$foo.father_id}" id="1" value="1"  {if $foo.son_id=="1"}checked="checked"{/if}/>
                            <label for="son_id">男</label>
                            <input type="radio" name="son_id{$foo.father_id}" value="2" {if $foo.son_id=="2"} checked="checked" {/if}/>
                            <label for="son_id">女</label>
                            <input type="radio" name="son_id{$foo.father_id}" value="3" {if $foo.son_id=="3"} checked="checked" {/if}/>
                            <label for="son_id">保密</label>
                              </td>
                   </tr>
{/foreach}
方法二:
{foreach  from="$information" item="foo" key="k"}
         <tr>
             <td>
                    {html_radios name=$foo.father_id options=$List checked=$foo.son_id }
             </td>
        </tr>
{/foreach}
說明:
    對於foreach的嵌套迴圈問題,涉及到二維數組的時候,往往總是選中最後一行的資訊(前面的沒有選中,被後面的覆蓋掉了,受到上一級id的牽制),所以name="son_id{$foo.father_id}"中要把上一級的id加上
  其中方法二中的$List是數組
$List = array (
       "1" => "男",
       "2" => "女",
       "3" => "保密",
    );

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.