當前位置:首頁 » 操作系統 » 購物車源碼

購物車源碼

發布時間: 2022-01-18 02:00:43

『壹』 購物車源碼思路php

首先確定購物車中商品結構(都有哪些欄位)。
比如:商品ID,商品名稱,數量,單價等等。
然後,將這些結構定義在數組里
array(
商品ID1=>array('name'=>'商品','num'=>1,'price'=>100),
商品ID2=>array('name'=>'商品','num'=>1,'price'=>100),
)
然後把這個大的數組保存在SESSION里。就可以了。
PHP有很多數組操作函數用起來也很方便。

『貳』 求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){
varewq=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 比較方便 有什麼不懂得可以問我

『叄』 哪位高手給一個完整的php+MYsql的購物車源代碼

我也正學呢我要的是PHP+mysql帶資料庫表的,但是沒找到完整免費下載的

『肆』 JAVA 購物車示例代碼

import java.awt.*;
import java.awt.event.*;
class ShopFrame extends Frame implements ActionListener
{ Label label1,label2,label3,label4;
Button button1,button2,button3,button4,button5;
TextArea text;
Panel panel1,panel2;
static float sum=0.0f;
ShopFrame(String s)
{ super(s);
setLayout(new BorderLayout());
label1=new Label("面紙:3元",Label.LEFT);
label2=new Label("鋼筆:5元",Label.LEFT);
label3=new Label("書:10元",Label.LEFT);
label4=new Label("襪子:8元",Label.LEFT);
button1=new Button("加入購物車");
button2=new Button("加入購物車");
button3=new Button("加入購物車");
button4=new Button("加入購物車");
button5=new Button("查看購物車");
text=new TextArea("商品有:"+"\n",5,10);
text.setEditable(false);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{ System.exit(0);
}
}
);
button1.addActionListener(this);
button2.addActionListener(this);
button3.addActionListener(this);
button4.addActionListener(this);
button5.addActionListener(this);
panel1=new Panel();
panel2=new Panel();
panel1.add(label1);
panel1.add(button1);
panel1.add(label2);
panel1.add(button2);
panel1.add(label3);
panel1.add(button3);
panel1.add(label4);
panel1.add(button4);
panel2.setLayout(new BorderLayout());
panel2.add(button5,BorderLayout.NORTH);
panel2.add(text,BorderLayout.SOUTH);
this.add(panel1,BorderLayout.CENTER);
this.add(panel2,BorderLayout.SOUTH);
setBounds(100,100,350,250);
setVisible(true);
validate();
}
public void actionPerformed(ActionEvent e)
{ if(e.getSource()==button1)
{ text.append("一個面紙、");
sum=sum+3;
}
else if(e.getSource()==button2)
{ text.append("一隻鋼筆、");
sum=sum+5;
}
else if(e.getSource()==button3)
{ text.append("一本書、");
sum=sum+10;
}
else if(e.getSource()==button4)
{ text.append("一雙襪子、");
sum=sum+8;
}
else if(e.getSource()==button5)
{
text.append("\n"+"總價為:"+"\n"+sum);
}
}

}

public class Shopping {
public static void main(String[] args) {
new ShopFrame("購物車");

}

}
我沒用Swing可能顯示不出來你的效果。不滿意得話我在給你編一個。

『伍』 完整的購物車系統源代碼

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

『陸』 你好,java購物車代碼

import java.awt.*;
import java.awt.event.*;
class ShopFrame extends Frame implements ActionListener
{ Label label1,label2,label3,label4;
Button button1,button2,button3,button4,button5;
TextArea text;
Panel panel1,panel2;
static float sum=0.0f;
ShopFrame(String s)
{ super(s);
setLayout(new BorderLayout());
label1=new Label("面紙:3元",Label.LEFT);
label2=new Label("鋼筆:5元",Label.LEFT);
label3=new Label("書:10元",Label.LEFT);
label4=new Label("襪子:8元",Label.LEFT);
button1=new Button("加入購物車");
button2=new Button("加入購物車");
button3=new Button("加入購物車");
button4=new Button("加入購物車");
button5=new Button("查看購物車");
text=new TextArea("商品有:"+"\n",5,10);
text.setEditable(false);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{ System.exit(0);
}
}
);
button1.addActionListener(this);
button2.addActionListener(this);
button3.addActionListener(this);
button4.addActionListener(this);
button5.addActionListener(this);
panel1=new Panel();
panel2=new Panel();
panel1.add(label1);
panel1.add(button1);
panel1.add(label2);
panel1.add(button2);
panel1.add(label3);
panel1.add(button3);
panel1.add(label4);
panel1.add(button4);
panel2.setLayout(new BorderLayout());
panel2.add(button5,BorderLayout.NORTH);
panel2.add(text,BorderLayout.SOUTH);
this.add(panel1,BorderLayout.CENTER);
this.add(panel2,BorderLayout.SOUTH);
setBounds(100,100,350,250);
setVisible(true);
validate();
}
public void actionPerformed(ActionEvent e)
{ if(e.getSource()==button1)
{ text.append("一個面紙、");
sum=sum+3;
}
else if(e.getSource()==button2)
{ text.append("一隻鋼筆、");
sum=sum+5;
}
else if(e.getSource()==button3)
{ text.append("一本書、");
sum=sum+10;
}
else if(e.getSource()==button4)
{ text.append("一雙襪子、");
sum=sum+8;
}
else if(e.getSource()==button5)
{
text.append("\n"+"總價為:"+"\n"+sum);
}
}

}

public class Shopping {
public static void main(String[] args) {
new ShopFrame("購物車");

}

}
我沒用Swing可能顯示不出來你的效果。不滿意得話我在給你編一個。

『柒』 jsp購物車代碼

query取得iframe中元素的幾種方法
在iframe子頁面獲取父頁面元素
代碼如下:
$(

『捌』 php 外貿購物車源碼,急!

淘寶搜關鍵字 PHP外貿網站源碼加本地測試

『玖』 JavaWeb開發中,怎麼根據用戶來實現單個的購物車,小白入門,請指教。能附上源碼跟容易理解謝謝!

1、這個如果連資料庫就很簡單了,cart資料庫,首先有id,proctID,然後userid,就是買家的id,然後PublishID,視為賣家id,其他的數據從proct表裡面讀,避免了重復存。
2、如果單純的起步學習,我還記得我小時候,老師講用session,用戶進入系統後如果要登錄就用用戶id去存session,不登錄就隨即生成一個id存session,購物車就根據用戶id讀session數據。

『拾』 購物車的Java代碼

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;public class ShoppingCartManager {

HashMap<String, String> hm=new HashMap<String, String>();
float totlePrice=0;
//添加book到購物車
public void addBook(String bookId,String bookQuantity){

if(hm.containsKey(bookId)){
int value=Integer.parseInt(hm.get(bookId));
value+=Integer.parseInt(bookQuantity);
hm.put(bookId, value+"");
}else{
hm.put(bookId, bookQuantity);
}
}

//修改數量
public void updateQuantity(String bookId,String bookQuantity){
hm.put(bookId, bookQuantity);
}

//獲取購物車的所有信息 並計算總價
public ArrayList<BookBean> getShoppingCart(){
ArrayList<BookBean> al=new ArrayList<BookBean>();
Iterator<String> i=hm.keySet().iterator();
String ids="";
BookTableManager btm=new BookTableManager();
while(i.hasNext()){
ids=ids+","+i.next();
}
al= btm.selectByBookIds(ids);

totlePrice=0; //清空總價,防止無限累計
for(int j=0;j<al.size();j++){
BookBean bb=al.get(j);
totlePrice+=bb.getPrice()*Integer.parseInt(getQuantityById(bb.getBookId()+""));
}

return al;
}

//獲取總價
public float getTotlePrice(){
return totlePrice;
}

//根據ID獲取數量
public String getQuantityById(String id){
String quantity=hm.get(id);
return quantity;
}

//清空購物車
public void clear(){
hm.clear();
}

//刪除購物車中的一本書
public void deleteById(String id){
hm.remove(id);
}
}

熱點內容
python和excel 發布:2024-03-29 07:47:03 瀏覽:860
postfix源碼下載 發布:2024-03-29 07:42:03 瀏覽:142
怎麼在電腦上玩手機伺服器 發布:2024-03-29 07:30:13 瀏覽:141
倍福加密 發布:2024-03-29 07:24:42 瀏覽:844
如何用密碼鎖住並隱藏工作表 發布:2024-03-29 07:03:28 瀏覽:327
按鍵精靈滑鼠腳本 發布:2024-03-29 06:47:41 瀏覽:20
pythonhome 發布:2024-03-29 06:47:36 瀏覽:170
dns配置錯誤怎麼修理 發布:2024-03-29 06:36:15 瀏覽:981
電信客戶6位密碼是什麼 發布:2024-03-29 06:35:42 瀏覽:566
b星演算法找門 發布:2024-03-29 06:27:13 瀏覽:774