一、使用{loop}
1、绑定下拉选项
- <select name="cityid" id="cityid">
- {loop $system_info["city"] $key $value}
- <option value="{$key}" {if $key==1}selected="selected"{/if}}>{$value}</option>
- {/loop}
- </select>
{loop}语法:{loop $a $b $c}与foreach($a as $b=>$c)相同,{loop $a $b}与foreach($a as $b)
2、绑定复选框,勾选保存后并把结果再显示出来.
- {loop $system_info['subline'] $key $name}
- <? $str=split (",", $company_info[subline]);//逗号分隔的字符串转化为数组
- $ishave=0;
- foreach($str as $v)
- {
- if($key==$v)
- {
- $ishave=1;
- }
- }
- if($ishave==1)
- {?>
- <label><input type="checkbox" name="subline[]" value="<?=$key?>" checked="checked" id="subline" />{$name}</label>
- <?}else{?>//开源软件:Vevb.com
- <label><input type="checkbox" name="subline[]" value="<?=$key?>" id="subline" />{$name}</label>
- <?}?>
- {/loop}
二、form表单选项控件
- function box($field, $value, $fieldinfo)
- {
- extract($fieldinfo);
- if(!$value) $value = $defaultvalue;
- if($boxtype == 'radio')
- {
- return form::radio($options, 'info['.$field.']', $field, $value, $cols, $css, $formattribute, $width);
- }
- elseif($boxtype == 'checkbox')
- {
- return form::checkbox($options, 'info['.$field.']', $field, $value, $cols, $css, $formattribute, $width);
- }
- elseif($boxtype == 'select')
- {
- return form::select($options, 'info['.$field.']', $field, $value, $size, $css, $formattribute);
- }
- elseif($boxtype == 'multiple')
- {
- return form::multiple($options, 'info['.$field.']', $field, $value, $size, $css, $formattribute);
- }
- }
页面调用:<?=form::select($options, 'info['.$field.']', $field, $value, $size, $css, $formattribute);?>参数:(数据源,name,id,value,大小,css,)
时间输入框:<?=form::date('starttime')?>
多行文本框:<?=form::textarea('beizhu')?>
编辑器:<textarea name="info[content]" id="content" cols="60" rows="8"></textarea><?=form::editor('content', 'introduce', 500, 200)?>
{form::editor('introduce','basic','100%',200,0)}
时间:<?= date('Y-m-d H:i:s',time())?>
三、{menu_linkage(40,'L_40')} 来自动产生无限级菜单选择框.
新闻热点
疑难解答