Smarty中内置标签 - 选择按钮的使用

函数类型的标签(smarty中内置标签):

    Array("语文","数学","英语","历史")  遍历成四个单选按钮 组成的按钮组

    <input type="radio" name="" value="" checked="">按钮名称

 

  单选按钮:

    {ts:html_radios name="" values="" options="" output="" separator=""  checked=""}

    Name:单选按钮组名字

    Values:单选按钮的value值组成的一维索引数组

    Output:单选按钮的文本信息组成的一维索引数组

    Options: 以value作为键名或者索引,以output作为数组元素组成的一维关联数组

    Checked:被选中的单选按钮的value值

    Separator: 设置单选按钮和单选按钮中间的格式标签

 

  复选按钮组:

    {ts:html_checkboxes name="" values="" options="" output="" separator=""  checked=""}

    Checked: 被选中的复选按钮组组成的一维索引数组

    其他值与单选按钮相同

 

  下拉列表框:

    {ts:html_options name="" values="" options="" output="" selected=""}

 

  【radios.php】

<?php
require_once("./smarty.inc.php");
$values = array('1001','1002','1003','1004');
$outputs = array('Chinese','Math','English','History');
$options = array('1001'=>'Chinese','1002'=>'Math','1003'=>'English','1004'=>'History');
$checked = 1003;
$checkeds = array('1001','1004');

$tpl -> assign("values",$values);
$tpl -> assign("outputs",$outputs);
$tpl -> assign("options",$options);
$tpl -> assign("checked",$checked);
$tpl -> assign("checkeds",$checkeds);

$tpl -> display("radios.html");
?>

  【radios.html】

{ts:html_radios name="c1" values=$values output=$outputs checked=$checked}
<hr/>
{ts:html_radios name="c2" options=$options checked=$checked}
<hr/>
{ts:html_radios name="c3" options=$options checked=$checked separator="<br/>"}
<hr/>
<hr/>
{ts:html_checkboxes name="c4" values=$values output=$outputs checked=$checkeds}
<hr/>
{ts:html_checkboxes name="c5" options=$options checked=$checkeds}
<hr/>
{ts:html_checkboxes name="c6" options=$options checked=$checkeds separator="<br/>"}

<hr/>
<hr/>
{ts:html_options name="c7" values=$values output=$outputs selected=$checked}
<hr/>
{ts:html_options name="c8" options=$options selected=$checked}
<hr/>
{ts:html_options name="c9" options=$options selected=$checked}

#在radios.php中获取前台radios.html中的值#

 

posted @ 2017-05-17 19:08  Shuo_128  阅读(695)  评论(0编辑  收藏  举报