标签:
在view目录下创建Index_aaa.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>select</title>
</head>
<body>
<tagLib name="html"/>
<html:select options="address" selected="sh" values="address"/>
</body>
</html>
public function aaa(){
$this->assign("address",["sh"=> "上海","天津","北京","郑州"]);
$this->display();
}
public function _ms($tag) {
$name = $tag[‘name‘];
$options = $tag[‘options‘];
$id = $tag[‘id‘];
$selected = $tag[‘selected‘];
$parseStr = ‘<select id="‘.$id.‘" name="‘.$name.‘" >‘;
$parseStr .=‘<?php foreach($‘.$options.‘ as $val) { ?>‘;
$parseStr .=‘<?php if("‘.$selected.‘"==$val) { ?>‘;
$parseStr .= ‘<option selected="selected" value="<?php echo $val ?>"><?php echo $val ?></option>‘;
$parseStr .= ‘<?php } else { ?><option value="<?php echo $val ?>"><?php echo $val ?></option>‘;
$parseStr .= ‘<?php } ?>‘;
$parseStr .= ‘<?php } ?>‘;
$parseStr .= ‘</select>‘;
return $parseStr;
}
public function _ms($tag) {
$name = $tag[‘name‘];
$options = $tag[‘options‘];
$id = $tag[‘id‘];
$selected = $tag[‘selected‘];
$parseStr = ‘<select id="‘.$id.‘" name="‘.$name.‘" >‘;
$parseStr .=‘<?php foreach($‘.$options.‘ as $val) { ?>‘;
/* $parseStr .=‘<?php if("‘.$selected.‘"==$val) { ?>‘;*///selected的值可以随便写
$parseStr .=‘<?php if($‘.$selected.‘==$val) { ?>‘;//值可以先分配再写
$parseStr .= ‘<option selected="selected" value="<?php echo $val ?>"><?php echo $val ?></option>‘;
$parseStr .= ‘<?php } else { ?><option value="<?php echo $val ?>"><?php echo $val ?></option>‘;
$parseStr .= ‘<?php } ?>‘;
$parseStr .= ‘<?php } ?>‘;
$parseStr .= ‘</select>‘;
return $parseStr;
}
public function aaa(){
$this->assign("address",["上海","天津","北京","郑州"]);
$this->assign("sh","天津");
$this->display();
}
<tagLib name="html"/>
<html:ms id="aa" name="uu" options="address" selected="sh"/><br>
public function _select($tag) {
$name = $tag[‘name‘];
$options = $tag[‘options‘];
$values = $tag[‘values‘];
$output = $tag[‘output‘];
$multiple = $tag[‘multiple‘];
$id = $tag[‘id‘];
$size = $tag[‘size‘];
$first = $tag[‘first‘];
$selected = $tag[‘selected‘];
$style = $tag[‘style‘];
$ondblclick = $tag[‘dblclick‘];
$onchange = $tag[‘change‘];
if(!empty($multiple)) {
$parseStr = ‘<select id="‘.$id.‘" name="‘.$name.‘" ondblclick="‘.$ondblclick.‘" onchange="‘.$onchange.‘" multiple="multiple" class="‘.$style.‘" size="‘.$size.‘" >‘;
}else {
$parseStr = ‘<select id="‘.$id.‘" name="‘.$name.‘" onchange="‘.$onchange.‘" ondblclick="‘.$ondblclick.‘" class="‘.$style.‘" >‘;
}
if(!empty($first)) {
$parseStr .= ‘<option value="" >‘.$first.‘</option>‘;
}
if(!empty($options)) {
$parseStr .= ‘<?php foreach($‘.$options.‘ as $key=>$val) { ?>‘;
if(!empty($selected)) {
$parseStr .= ‘<?php if(!empty($‘.$selected.‘) && ($‘.$selected.‘ == $val || in_array($key,$‘.$selected.‘))) { ?>‘;
$parseStr .= ‘<option selected="selected" value="<?php echo $val ?>"><?php echo $val ?></option>‘;
$parseStr .= ‘<?php }else { ?><option value="<?php echo $val ?>"><?php echo $val ?></option>‘;
$parseStr .= ‘<?php } ?>‘;
}else {
$parseStr .= ‘<option value="<?php echo $val ?>"><?php echo $val ?></option>‘;
}
$parseStr .= ‘<?php } ?>‘;
}else if(!empty($values)) {
$parseStr .= ‘<?php for($i=0;$i<count($‘.$values.‘);$i++) { ?>‘;
if(!empty($selected)) {
$parseStr .= ‘<?php if(isset($‘.$selected.‘) && ((is_string($‘.$selected.‘) && $‘.$selected.‘ == $‘.$values.‘[$i]) || (is_array($‘.$selected.‘) && in_array($‘.$values.‘[$i],$‘.$selected.‘)))) { ?>‘;
$parseStr .= ‘<option selected="selected" value="<?php echo $‘.$values.‘[$i] ?>"><?php echo $‘.$output.‘[$i] ?></option>‘;
$parseStr .= ‘<?php }else { ?><option value="<?php echo $‘.$values.‘[$i] ?>"><?php echo $‘.$output.‘[$i] ?></option>‘;
$parseStr .= ‘<?php } ?>‘;
}else {
$parseStr .= ‘<option value="<?php echo $‘.$values.‘[$i] ?>"><?php echo $‘.$output.‘[$i] ?></option>‘;
}
$parseStr .= ‘<?php } ?>‘;
}
$parseStr .= ‘</select>‘;
return $parseStr;
}
window.UEDITOR_HOME_URL = "/Public/js/ueditor/";
$parseStr = ‘<script id="container" name="content" type="text/plain">这里写你的初始化内容</script><script type="text/javascript" src="__ROOT__/Public/js/ueditor/ueditor.config.js"></script><script type="text/javascript" src="__ROOT__/Public/js/ueditor/ueditor.all.js"></script><script type="text/javascript"> var ue = UE.getEditor("container",{emotionLocalization:true,lang:"zh-cn",initialFrameWidth:"80%",initialFrameHeight:320,textarea:"content",initialContent:"欢迎留言!", autoClearinitialContent:true}); </script>‘;
<tagLib name="html"/>
<html:editor type="UEDITOR"></html:editor>
标签:
原文地址:http://www.cnblogs.com/lsr111/p/4631828.html