开发者

question in html_checkboxes loop index in smarty template

i want know how to get the index of html_checkboxes loop ind开发者_JS百科ex with smarty for each checkbox ??

http://www.smarty.net/manual/en/language.function.html.checkboxes.php


You would have to modify the function to do that. As written it's not designed to give you that information. If you need the index you can implement your check-boxes in a smarty loop:

<?php

$smarty->assign('checkboxes', array( 'value1', 'value2','value3','value4' ) );

?>

And your smarty code:

{ foreach from=$checkboxes item=value name=checkboxloop }
<input type="checkbox" name="whatever_name[{$smarty.foreach.checkboxloop.index}]" value="{$value}" />
{ /foreach }

So in that case the index (starting from zero) is access by {$smarty.foreach.checkboxloop.index} if you want it starting from 1 it's {$smarty.foreach.checkboxloop.iteration}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜