search
HomeBackend DevelopmentPHP Tutorial大神帮我看看这段代码怎么改啊

	<div class="x_box" onmouseover="kj.addClassName(this,&#39;x_sel&#39;);" onmouseout="kj.delClassName(this,&#39;x_sel&#39;);" onclick="thisjs.cart_add({id:&#39;41&#39;,name:&#39;酸辣鸡杂&#39;,pic:&#39;/upload/attatch/2012/酸辣鸡杂饭_50_50.gif&#39;,price:&#39;13.00&#39;,type:&#39;6&#39;});">				<li class="x_tit">【酸辣鸡杂】</li>				<li class="x_intro">主料:</li>				<li class="x_pic"><img  src="/static/imghwm/default1.png"  data-src="./index_files/酸辣鸡杂饭.gif"  class="lazy"   alt="大神帮我看看这段代码怎么改啊" ></li>				<li class="x_tip menu_state_on"><font   style="max-width:90%">13</font>.00</li>			</div>



这是别人的,我要用smarty 输出查询到的结果,应该改哪里


回复讨论(解决方案)

首先 得把价格改了 
还有图片

还有点击之后加入购物车的价格

你要在哪改代码呀,方便把要改的代码发出来吗,你发的那个代码我实在看不出在哪改。

你要在哪改代码呀,方便把要改的代码发出来吗,你发的那个代码我实在看不出在哪改。  
不好意思,我的意思是原来的js 不变 改的是价格和名称(这些都是由smarty)遍历出来的


小弟初学者,对上面的html 半点不懂,所以求教。贴一下smarty的遍历

 

<?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?}*/

哦,你发的这个代码我也有点看不懂,仔细看了下你上面的html代码:
当点击的时候,触发的是这个方法:thisjs.cart_add ,这个方法有两个参数传递,一个id,一个name,你把这个两个参数换成你要传递的两个值试一下。
由于thisjs.cart_add()代码不知道如何写的,我只能分析到这里了。

哦,你发的这个代码我也有点看不懂,仔细看了下你上面的html代码:
当点击的时候,触发的是这个方法:thisjs.cart_add ,这个方法有两个参数传递,一个id,一个name,你把这个两个参数换成你要传递的两个值试一下。
由于thisjs.cart_add()代码不知道如何写的,我只能分析到这里了。


另外一部分代码是这样子的  不是我写的,我可看不懂 是js

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();});

onmouseout="kj.delClassName(this,&#39;x_sel&#39;);" onclick="thisjs.cart_add({id:&#39;41&#39;,name:&#39;酸辣鸡杂&#39;,pic:&#39;/upload/attatch/2012/酸辣鸡杂饭_50_50.gif&#39;,price:&#39;13.00&#39;,type:&#39;6&#39;});


传的这个值 里面的:'6'    是什么意思 

传值传到哪去了呢

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

PHP Logging: Best Practices for PHP Log AnalysisPHP Logging: Best Practices for PHP Log AnalysisMar 10, 2025 pm 02:32 PM

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Explain the concept of late static binding in PHP.Explain the concept of late static binding in PHP.Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Customizing/Extending Frameworks: How to add custom functionality.Customizing/Extending Frameworks: How to add custom functionality.Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools