0
我想知道如何使用smarty爲每個複選框獲取html_checkboxes循環索引的索引?html_checkboxes在smarty模板中的循環索引問題
http://www.smarty.net/manual/en/language.function.html.checkboxes.php
我想知道如何使用smarty爲每個複選框獲取html_checkboxes循環索引的索引?html_checkboxes在smarty模板中的循環索引問題
http://www.smarty.net/manual/en/language.function.html.checkboxes.php
你將不得不修改函數來做到這一點。正如所寫的,它不是爲了給你提供這些信息。如果你需要的指數,你可以在一個智者循環實現您的複選框:
<?php
$smarty->assign('checkboxes', array('value1', 'value2','value3','value4'));
?>
和你的Smarty代碼:
{ foreach from=$checkboxes item=value name=checkboxloop }
<input type="checkbox" name="whatever_name[{$smarty.foreach.checkboxloop.index}]" value="{$value}" />
{ /foreach }
因此,在這種情況下,指數(從零開始)是獲得通過{$smarty.foreach.checkboxloop.index}
如果你想要它從1開始它的{$smarty.foreach.checkboxloop.iteration}
除了有索引什麼是目標,獲取索引的目的是什麼? – mcgrailm 2010-10-08 18:23:18