當前位置:首頁 » 網購平台 » 購物車頁面代碼
擴展閱讀
寧波奧德賽優惠價格 2021-03-15 14:26:02
丹尼斯購物卡能掛失么 2021-03-15 14:25:58
淘寶購物指紋驗證失敗 2021-03-15 14:24:44

購物車頁面代碼

發布時間: 2021-01-26 04:47:03

A. 求html購物車代碼,,效果如圖顯示

<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>修改訂單</title>
<styletype="text/css">
body{
font-size:13px;
line-height:25px;
}
table{
border-top:1pxsolid#333;
border-left:1pxsolid#333;
width:400px;
}
td{
border-right:1pxsolid#333;
border-bottom:1pxsolid#333;
text-align:center;
}
.title{

font-weight:bold;
background-color:#cccccc;
}
inputtext{
width:100px;
}

</style>
<scripttype="text/javascript">
functionaddRow(){
//行的長度
varrowlength=document.getElementById("order").rows.length;
//得到整個表格對象
varorder=document.getElementById("order").insertRow(rowlength-1);
order.id=rowlength-1;
//插入列
varcel1=order.insertCell(0).innerHTML="游戲光碟";
varcel2=order.insertCell(1).innerHTML="34";
varcel3=order.insertCell(2).innerHTML="&yen;58.40";
varcel4=order.insertCell(3).innerHTML="<inputtype="button"value="刪除"onclick="delRow('"+(rowlength-1)+"')"/>"+"<inputtype="button"value="修改"onclick="editRow('"+(rowlength-1)+"')"/>"
}
functiondelRow(qwe){
=document.getElementById(qwe).rowIndex;
document.getElementById("order").deleteRow(ewq);
}
functioneditRow(rowID){
varrow=document.getElementById(rowID);
varcel=row.cells;
vartext=cel[1].innerHTML;
cel[1].innerHTML="<inputtype='text'value='"+text+"'style='width:40px;'>"
cel[3].lastChild.value="確定";
cel[3].lastChild.setAttribute("onclick","update('"+rowID+"')");
}

functionupdate(qwe){
varrow=document.getElementById(qwe);
varcel=row.cells;
vartext=cel[1].lastChild.value;
cel[1].innerHTML=text;
cel[3].lastChild.value="修改";
cel[3].lastChild.setAttribute("onclick","editRow('"+qwe+"')");
}
/*

functionadd(){
vara=document.getElementById("order").rows.length;
varb=document.getElementById("order").insertRow(a-1);
varone1=b.insertCell(0).innerHTML="123";
}
*/
</script>
</head>
<body>
<tableborder="0"cellspacing="0"cellpadding="0"id="order">
<trclass="title">
<td>商品名稱</td>
<td>數量</td>
<td>價格</td>
<td>操作</td>
</tr>
<trid="1">
<td>防滑真皮休閑鞋</td>
<td>12</td>
<td>&yen;568.50</td>
<td><inputname="rowdel"type="button"value="刪除"onclick='delRow("1")'/>
<inputid="edit1"type="button"value="修改"onclick='editRow("1")'/></td>
</tr>
<tr>
<tdcolspan="4"style="height:30px;">
<inputname="addOrder"type="button"value="增加訂單"onclick="addRow()"/></td>
</tr>
</table>
</body>
</html>

這個是我原來上學的時候練習的代碼,練習的是基礎的jsDOM操作,不過建議以後用Jquery 比較方便 有什麼不懂得可以問我

B. jsp購物車代碼

有人貼了轉發我一下

C. 完整的購物車系統源代碼

我是用mcmore購物商城系統,資料庫跟你一樣,是MySQL,Java開發的,要不你去官網看看吧,在這說不清楚。

D. java簡單的購物車代碼

packageTest;
importjava.util.LinkedHashMap;
importjava.util.Map;
importjava.util.Map.Entry;
importjava.util.Scanner;

publicclassTest{
publicstaticvoidmain(String[]args){
init();//初始化
Map<String,String>map=newLinkedHashMap<>();
while(true){
Scannerin=newScanner(System.in);
map=buy(in,map);//選擇
System.out.println();
System.out.println("還要繼續購物嗎?(Y/N)");
Stringjx=in.nextLine();
if(jx.equals("N")){
break;
}
}
print(map);
}
publicstaticvoidprint(Map<String,String>m){
System.out.println(" ******************");
System.out.println("購物車清單");
Integerhj=0;
for(Entry<String,String>entry:m.entrySet()){
Stringkey=entry.getKey();
Stringvalue=entry.getValue();
if(key.equals("1")){
hj+=Integer.parseInt(value)*3;
System.out.println("哇哈哈純凈水:"+value+"件,合計:¥"+Integer.parseInt(value)*3);
}elseif(key.equals("2")){
hj+=Integer.parseInt(value)*5;
System.out.println("康師傅方便麵:"+value+"件,合計:¥"+Integer.parseInt(value)*5);
}elseif(key.equals("3")){
hj+=Integer.parseInt(value)*4;
System.out.println("可口可樂:"+value+"件,合計:¥"+Integer.parseInt(value)*4);
}
}
System.out.println("合計金額:¥"+hj);
}
publicstaticvoidinit(){
System.out.println("******************");
System.out.println(" 商品列表 ");
System.out.println("商品名稱價格");
System.out.println("1.哇哈哈純凈水¥3");
System.out.println("2.康師傅方便麵¥5");
System.out.println("3.可口可樂¥4");
System.out.println("******************");
}

publicstaticMap<String,String>buy(Scannerscan,Map<String,String>m){
System.out.print("請輸入編號:");
Stringbh=scan.nextLine();
System.out.print("請輸入購買數量:");
Stringnum=scan.nextLine();
if(m.size()>0&&m.keySet().contains(bh)){
m.put(bh,(Integer.parseInt(bh)+Integer.parseInt(num))+"");
}else{
m.put(bh,num);
}
returnm;
}
}

E. 該如何寫購物車數量效果代碼

代碼我先不貼了,我提供下思路,具體的寫法你自己會的。分數你看回著給啦
首先得到該產品答的數量最大值
獲取文本框的onchange事件,在此事件中,比較文本值和最大值,如果小於最大值,就不做任何操作,如果大於最大值,就彈出對話框,已經超過了最大數量,或者在頁面上設置一個顯示提示信息的文本框。

F. 想求一個完整的ASP購物車代碼

示用戶信息
首先登陸: 就是判斷資料庫里的記錄 是否存在用戶名欄位=帳號 and 密碼欄位=密碼 如果有這條記錄 那麼就是登陸成功 用session記住他的帳號 這就是登陸
購物車: 就是有個表 記錄商品的唯一值的欄位(一般是id欄位)和用戶的唯一欄位(一般是帳號) 這樣這個商就屬於這個人購物車內的商品了 一般有個商品個數欄位 記錄這個人買了多少件這個商品
顯示:(select * from [表] where 條件)這個是查詢sql 你應該會用吧 如果是查詢某人的購物車 就這樣寫(select * from [購物車表] where [用戶名欄位] = 用戶)上面已經說了 購物車表裡要有個用戶名欄位 來記錄是哪個用戶存放的物品
刪除:(delete from [購物車表] where [id]=記錄id and [用戶名欄位]=用戶)上面顯示里已經獲取到記錄的id和其他信息 在這里只需要id和用戶名 其實只需要id就可以要用戶名是為了更保險 有了用戶名欄位的限制 就只樣自己刪除自己的記錄
顯示用戶信息:如果你不會顯示用戶信息的話 那你還是去看看sql吧 (select * from [會員表] where [用戶名]=用戶名)獲取這個sql的記錄集
response.write(rs.("用戶名"))這樣就能在屏幕上列印出用戶名欄位的內容 其他欄位同上

G. jsp購物車代碼

//shopping.html
<html>
<head><title>shopping stor</title></head>
<body>
<form action="carts.jsp" target="post">
<br>
please select the item that you want to buy
<br>
<select name="item">
<option>book:old man and the sea
<option>x-box game machine
<option>mp3 player
<option>cce
<option>book:jsp programming
<option>cd "the endless love"
<option>dvd "gone with the wind"
</select>
<br>
<input type="submit" name="submit" value="add">
<input type="submit" name="submit" value="remove">
</form>
</body>

</html>
------------------------------------------------------------------
//carts.jsp
<%@page contentType="text/html;charset=ISO8859_1" %>
<html>
<jsp:useBean id="cart" scope="session" class="test.DummyCart"/>
<jsp:setProperty name="cart" property="*"/>

<%
cart.processRequest();
%>
<br>
<ol>
you have chosen these items:
<%
String []items=cart.getItems();
for(int i=0;i<items.length;i++)
{
%>
<li><%=items[i] %></li>
<%
}
%>
</ol>
<hr>
<%@include file="shopping.htm" %>

</html>
---------------------------------------------------------------------//DummyCart.java
package test;
import javax.servlet.http.*;
import java.util.Vector;
import java.util.Enumeration;
public class DummyCart
{
Vector v = new Vector();
String submit=null;
String item= null;
private void addItem(String name)
{
v.addElement(name);
}

private void removeItem(String name)
{
v.removeElement(name);
}

public void setItem(String s)
{
item=s;
}

public void setSubmit(String s)
{
submit=s;
}

public String[] getItems()
{
String []s=new String[v.size()];
v.Into(s);
return s;
}

public void processRequest()
{
if(submit==null)
addItem(item);
if(submit.equals("add"))
addItem(item);
else if (submit.equals("remove"))
removeItem(item);
reset();
}

private void reset()
{
submit=null;
item=null;
}

}

----------------------------------------------------------------------
上面是一個簡單的例子,功能都能實現,對網頁效果要求更漂亮些的可做一些修改。

H. 用jsp和資料庫做購物車,怎麼能通過點擊按鈕把購買數量和商品信息傳給購物車頁面,急!!下面是部分代碼

你把購買的數量和商品信息做成一個javabean,然後把這個javabean存在session裡面,你點擊按鈕就向伺服器端發出請求,然後伺服器端處理請求後用jsp顯示,這樣就可以了呀

I. 想做一個簡單的購物車界面,非常簡單就行有代碼!用div+css做就可以

購物車外是可以的 但是核心最好還是用程序本來的核心如果自己寫,很有單獨

J. 哪裡可以下載到免費的購物車網頁模板和源代碼

免費模板素材網上有啊。版權。http://hi..com/mianfeimoban/blog/item/4947eb0b576dfe26e92488bd.html