每一个你不满意的现在,都有一个你不努力的曾经. 网站首页 > 其他
jquery 、thinkphp商品无限极分类
发布时间:2018-12-27 14:12:55 修改时间:2018-12-29 08:55:20 阅读:6729 评论:0 0
运行中主要文件,仅限参考
HTML:
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{$CONF['shopTitle']['fieldValue']}后台管理中心</title>
<link href="__PUBLIC__/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="__ROOT__/Apps/Admin/View/css/AdminLTE.css" rel="stylesheet" type="text/css" />
<!--[if lt IE 9]>
<script src="__PUBLIC__/js/html5shiv.min.js"></script>
<script src="__PUBLIC__/js/respond.min.js"></script>
<![endif]-->
<!--script src="__PUBLIC__/js/jquery.min.js"></script-->
<script src="__PUBLIC__/plugins/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/plugins/plugins/plugins.js"></script>
<script src="__PUBLIC__/plugins/formValidator/formValidator-4.1.3.js"></script>
<script src="__PUBLIC__/plugins/kindeditor/kindeditor.js"></script>
<script src="__PUBLIC__/plugins/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
var url="{:U('News/typeTree')}";
</script>
<script src="__PUBLIC__/js/bindDB.js"></script>
</head>
<script>
$(function () {
bindDB({ajaxurl:"{:U('News/typeTree')}"});
KindEditor.ready(function(K) {
editor1 = K.create('textarea[name="articleContent"]', {
height:'350px',
allowFileManager : false,
allowImageUpload : true,
items:[
'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|','image','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
'anchor', 'link', 'unlink', '|', 'about'
],
afterBlur: function(){ this.sync(); }
});
});
$.formValidator.initConfig({
theme:'Default',mode:'AutoTip',formID:"myform",debug:true,submitOnce:true,onSuccess:function(){
edit();
return false;
},onError:function(msg){
}});
$("#articleTitle").formValidator({onFocus:"请输入文章标题"}).inputValidator({min:1,max:100,onError:"请输入100字以内文章标题"});
$("#catId").formValidator({onFocus:"请选择文章分类"}).inputValidator({min:1,onError: "请选择文章分类"});
$("#articleKey").formValidator({onFocus:"请输入关键字"}).inputValidator({min:1,max:80,onError:"请输入关键字"});
});
</script>
<body class="wst-page">
<form name="myform" method="post" id="myform" action="{:U('News/newsUp')}" autocomplete="off">
<table class="table table-hover table-striped table-bordered wst-form">
<tr>
<th width='120' align='right'>文章标题<font color='red'>*</font>:</th>
<td><input type='text' id='newsTitle' class="form-control wst-ipt" name="newsTitle" value="{$list.newsTitle}" maxLength='25'/>
<input type='hidden' name="type" value="{$list.type}">
</td>
</tr>
<tr>
<th align='right'>分类<font color='red'>*</font>:</th>
<td>
<select id='goodsCatId1' class="bindDB" name='select_0'>
<option value='0'>请选择</option>
<volist name="goodsCatsList" id="vo">
<option value='{$vo['catId']}'>{$vo.catName}</option>
</volist>
</select>
</td>
</tr>
<tr>
<th align='right'>是否显示<font color='red'>*</font>:</th>
<td>
<label>
<input type='radio' id='isShow1' name='isShow' value='1' <if condition="$object['isShow'] ==1 ">checked</if> />显示
</label>
<label>
<input type='radio' id='isShow0' name='isShow' value='0' <if condition="$object['isShow'] ==0 ">checked</if> />隐藏
</label>
</td>
</tr>
<tr>
<th align='right'>关键字<font color='red'>*</font>:</th>
<td>
<input type='text' id='newsKey' class="form-control wst-ipt" name="newsKey" value="{$list.newsKey}" maxLength='80'/>
<input type="hidden" name="newsId" value="{$list.newsId}">
</td>
</tr>
<tr>
<th align='right'>内容<font color='red'>*</font>:</th>
<td>
<textarea id='newsContent' name='newsContent' value="{$list.newsContent}" style='width:80%;height:400px;'>{$list.newsContent}</textarea>
</td>
</tr>
<tr>
<td>
<input class="btn btn-success" type='submit' value="提交">
</td>
</tr>
</table>
</form>
</body>
</html>
js:
$(document).ready(function(){
function bindDB(options){
//alert(options);
var opt = options || {},
$bindDB = $(".bindDB"),
len = 0,
nameText = "";
if(!$bindDB[0]){$.error("对象不存在!");return false;};
len = $bindDB.length;
$(".bindDB").live("change",function() {
if(this.name && this.tagName == "SELECT")
{
var that = $(this);
//alert(that);
that.nextAll(".bindDB").remove();
len=$(".bindDB").length;
//alert(len);
if(/_/g.test(this.name)){
nameText = this.name.split("_")[0]+"_";
this.name = nameText+(len-1);
}else{
nameText = this.name+"_";
this.name = nameText+(len-1);
};
$.ajax({
url:url,
dataType:"json",
type:'post',
data:{id:$(this).val()},
timeout:5000,
error: function(error){
alert("网络超时!");
},
success: function(data){
//console.
//alert(data);
//var data = eval("("+data+")");
console.log(data);
var option = "";
$.each(data,function(k,v){
option+= "<option value='"+v.catId+"'>"+v.catName+"</option>"
});
that.after("<select class='bindDB' name='"+nameText+len+"'>"+option+"</select>");
}
});
}
});
};
//bindDB();
window.bindDB = bindDB;
})
thinkphp:
public function typeTree(){
//获取商品分类信息
$catId=I('post.id');
$this->ajaxReturn($catId);exit;
$m = M('goods_cats');
$rs = $m->where('parentId='.$catId)->select();
echo json_encode($rs);
}
回复列表
关键字词:nbsp,span,style,font-size,1px,gt
上一篇:css常用属性