4,250
社区成员
发帖
与我相关
我的任务
分享 <div class="x_box" onmouseover="kj.addClassName(this,'x_sel');" onmouseout="kj.delClassName(this,'x_sel');" onclick="thisjs.cart_add({id:'41',name:'酸辣鸡杂',pic:'/upload/attatch/2012/酸辣鸡杂饭_50_50.gif',price:'13.00',type:'6'});">
<li class="x_tit">【酸辣鸡杂】</li>
<li class="x_intro">主料:</li>
<li class="x_pic"><img src="./index_files/酸辣鸡杂饭.gif"></li>
<li class="x_tip menu_state_on"><font style="font-size:30px;font-size:40px\9">13</font>.00</li>
</div>
onmouseout="kj.delClassName(this,'x_sel');" onclick="thisjs.cart_add({id:'41',name:'酸辣鸡杂',pic:'/upload/attatch/2012/酸辣鸡杂饭_50_50.gif',price:'13.00',type:'6'});
传的这个值 里面的:'6' 是什么意思
传值传到哪去了呢kj.onresize(function() {
me_resize();
});
kj.onload(function() {
me_resize();
kj.show("#id_cart_menu");
});
function me_resize(){
var h = document.documentElement.clientHeight - 32;
var l = (document.documentElement.clientWidth - 980)/2;
kj.set("#id_cart_menu" , 'style.top' , h + "px");
kj.set("#id_cart_menu" , 'style.left' , l + "px");
}
var thisjs = new function() {
this.mintotal = kj.toint('10');//最低起送价
this.total = 0;//合计金额
this.cart_show = 0;
this.cart_lock = false;
this.cart_add = function(o) {
var obj = kj.obj("#id_cart_box");
var obj_cart_num = kj.obj("#id_cart_num_" + o.id);
if(obj_cart_num) {
var obj_cart_price = kj.obj("#id_cart_price_" + o.id);
obj_cart_num.value = kj.toint(obj_cart_num.value) + 1;
obj_cart_price.innerHTML = "¥"+kj.toint(obj_cart_num.value) * o.price;
} else {
var obj_li=document.createElement("li");
obj_li.id = "id_cart_" + o.id;
obj_li.innerHTML = '<input type="hidden" name="cartid[]" value="'+o.id+'"><input type="hidden" name="price[]" id="id_price_'+o.id+'" value="'+o.price+'"><span class="col1">'+o.name+'</span><span class="col2">¥'+kj.toint(o.price)+'</span><span class="col3"><input type="button" name="btn_jian" value="" class="x_jian" onclick="thisjs.change_num('+o.id+',-1);"> <input type="text" name="num'+o.id+'[]" value="1" id="id_cart_num_'+o.id+'" class="x_num" onkeyup="thisjs.change_num('+o.id+')"> <input type="button" name="btn_jian" value="" class="x_jia" onclick="thisjs.change_num('+o.id+',1);"></span><span class="col4" id="id_cart_price_'+o.id+'">¥'+kj.toint(o.price)+'</span><span class="col5"><input type="button" name="btn_del" value="" class="x_del" onclick="thisjs.del('+o.id+')"></span>';
obj.appendChild(obj_li);
}
this.refresh_price();
}
//删除
this.del = function(id) {
kj.remove("#id_cart_"+id);
this.refresh_price();
}
//改变数量
this.change_num = function(id , num) {
var obj_cart_num = kj.obj("#id_cart_num_" + id);
val = kj.toint(obj_cart_num.value);
if(num) {
val+=num;
if(val<1) return;
obj_cart_num.value = val;
}
if(obj_cart_num) {
var obj_cart_price = kj.obj("#id_cart_price_" + id);
var obj_price = kj.obj("#id_price_"+id);
if(obj_cart_price) obj_cart_price.innerHTML = "¥"+val * kj.toint(obj_price.value);
this.refresh_price();
}
}
//刷新价格
this.refresh_price = function() {
var obj = kj.obj("#id_cart_box .col4");
var price = 0;
for(var i = obj.length-1 ; i >=0 ; i--) {
price += kj.toint(obj[i].innerHTML);
}
kj.set("#id_cart_menu .x_2" , 'innerHTML' , '共 <font style="font-size:14px;color:#FF821E">'+obj.length+'</font> 份,合计:');
kj.set("#id_cart_menu .x_3" , 'innerHTML' , '¥'+price);
this.total = price;
if(price == 0) {
this.showcart(0);
} else {
this.showcart(1);
}
return price;
}
//清空
this.clear = function() {
var obj = kj.obj("#id_cart_box");
obj.innerHTML = '';
this.refresh_price();
}
this.cart_init = function() {
}
//提交,保存到cookie
this.cart_submit = function() {
var obj = kj.obj("#id_cart_box li");
//检查是否已点餐
if(obj.length<1) {
alert("温馨提示:您的购物车是空的,请先点餐!");
return false;
}
//点餐价格是否达到起送价
if(this.mintotal>0 && this.total < this.mintotal) {
alert("温馨提示:由于人力成本等问题,外卖定餐需起送不得低于"+this.mintotal+"元,不便之处还请您多多包涵!");
return false;
}
var i,val,j,arr_1=[];
obj = kj.obj("#id_cart_box :cartid[]");
for(i = 0 ; i < obj.length ; i++ ) {
val = kj.toint(kj.obj("#id_cart_num_"+obj[i].value).value);
for(j=0;j<val;j++) {
arr_1[arr_1.length] = obj[i].value;
}
}
var str_ids = "0:" + arr_1.join("|");
kj.cookie_set("cart_ids" , str_ids , 24);
window.location.href = "?app_act=cart";
}
this.mouseover = function(id) {
var obj = kj.obj("#id_nosel_"+this.orderid);
if(obj) obj.className = 'x_nosel';
kj.obj("#id_nosel_"+id).className = 'x_sel1';
this.orderid = id;
kj.addClassName("#id_li_"+id , "x_sel2");
}
this.mouseout = function(id) {
var obj = kj.obj("#id_nosel_"+this.orderid);
if(obj) obj.className = 'x_nosel';
kj.delClassName("#id_li_"+id , "x_sel2");
}
this.showcart_fixed = function(obj) {
if(obj.className == 'x_4') {
this.showcart(1);
} else {
this.showcart(0);
}
}
this.showcart = function(show) {
if(this.cart_lock) return;
if(this.cart_show == show) return;
this.cart_show = show;
var h = document.documentElement.clientHeight - 32;
var obj = kj.obj("#id_cart_menu");
var offset = kj.offset(obj);
var top = offset.top;
this.cart_lock = true;
if(show) {
kj.set("#id_cart_menu .x_top .x_4" , 'className' , 'x_6');
this.showcart_time('#id_cart_menu' , top , h-120 , -10);
} else {
kj.set("#id_cart_menu .x_top .x_6" , 'className' , 'x_4');
this.showcart_time('#id_cart_menu' , top , h , 10);
}
}
this.showcart_time = function(id , top , top_target , val) {
var obj = kj.obj(id);
var x = top - top_target;
if(val > 0) x = x * -1;
if( x > 0 ) {
kj.set(obj, 'style.top' , top+'px');
top+=val;
window.setTimeout("thisjs.showcart_time('" + id + "'," + top + "," + top_target + "," + val + ")", 20);
} else {
kj.set(obj, 'style.top' , top_target+'px');
this.cart_lock = false;
}
}
}
kj.onload(function(){
thisjs.cart_init();
});<?php
include 'config.php';
include 'smarty.php';
$tpl->assign ("title", "欢迎访问我的订餐系统");
$tpl->display("index.tpl");
$sql="select * from menu";
$query=mysql_query("$sql" );
while(($row=mysql_fetch_array($query))==true){
$menuarray[]=$row;
}
$tpl->assign("menu_array",$menuarray);
/*html 遍历
{?section name=list loop=$menu_array?}
{?$menu_array[list].menu_name?} //菜名
{?$menu_array[list].price?} //价格
{?sectionelse?}
There is no orders.
{?/section?}
*/