㈠ js如何把購物車列表裡所有選中的id放進不同的數組里list格式是這樣的
看你的數抄據格式,應該是一個標準的jsonarray格式,但是感覺你沒有說清楚,我猜測一下吧。現在有4個商品,id分別是3,4,5,6。需要根據用戶具體選擇了哪個商品,然後將商品從購物車中放入你要的數組中,數組格式是jsonarray格式。其實不是如何放入數組中,而是根據用戶的選擇如何生成最終的數組。
比如用戶選擇了兩個3,三個5,一個6,那麼你生成的數組應該是
var list=[{id:3,number:2},{id:5,number:3},{id:6,number:1}];
還是不了解你具體的業務,不明白為什麼你的數據格式要那麼復雜,可以將業務邏輯將清楚,再討論一下。
㈡ html或html5實現購物車頁面或者多個商品展示頁面,商品添加修改、商品篩選排序等功能,盡你可能考慮全面
有。。。償、、、、
可、。。。做。。
㈢ html5怎麼實現當購物車裡面有條消息時在右上角有個數字
<style type="text/css">
sup{
background: red;
color: white;
border-radius: 5px; /*圓角*/
padding: 0px 3px; /*左右邊距*/
top: -1em; /*數字離圖片右回上角的高度答*/
}
#shop{
margin-top:10px;
}
</style>
<div id="shop">
<img src="images/1.jpg"/ width="25" height="25">
<sup>1</sup>
</div>
㈣ 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可能顯示不出來你的效果。不滿意得話我在給你編一個。
㈤ html5中搜索欄旁的放大鏡和購物車圖標不顯示
圖片不顯示最常見的就是路徑問題,你要確定路徑中沒中文和空格。
如果是其他原因,最好貼上代碼。
㈥ 雙11當天,近5萬元購物車被摳門男友「清」空,要不要和他分手
圍城有話:
說實話,作為談了兩年多的男女朋友,男友的行為確實有點過了。如此清空女友購物車,確實有點沖動了。當然,話說回來,雙11購物是正常的,比平時多一些購物,看重優惠也是可以理解的,但購物需要理性,需要結合自己的情況來,不可超過自己的實際情況,對於一些無謂的消費要理性控制。
而作為男友,如果覺得女友的購物中有不需要或者覺得浪費錢不實用的東西,可以和女友商量一下,看看那些不必要的購物可以先不買,等需要的時候再買。或許這樣溝通之後,女友也會理性接受。但不吭聲自作聰明地刪掉所有購物商品,想聰明的歪解女友意思,我想,一定會聰明反被聰明誤。結果,被女友分手,值得不值得呢?
最後,我覺得,如果因此分手,可能也是說明兩個人的感情早就出現了問題。從男友的角度來說,會覺得交往兩年多,過了三個雙11,這連年遞增的購物車,讓他產生壓力,或許他內心也有了放手的意思。不然也不會在你生氣之後,不主動聯系你加回好友。所以,好好想想,是不是也有這種可能。如果,你內心不想分手,那若他主動聯系你,順台階而下,好好溝通,話說開,弄清原因。找找感情存在的問題。彼此改變和調整。
㈦ 求PHP里的TP5的購物車代碼
可以參考如下代碼
<?php
classCartextendsThink{
//當前購物車名
public$sessionName;
//購物車總價格
public$totalPrice
publicfunction__construct($sessionName)
{
$this->sessionName=$sessionName;
if(!isset($_SESSION[$this->sessionName]))
{
$_SESSION[$this->sessionName]="";
}
}
//獲取購物車的信息
publicfunctiongetCart(){
$cur_cart_array=$_SESSION[$this->sessionName];
return$cur_cart_array;
}
//獲取購物車商品清單
publicfunctiongetCartList()
{
$cur_cart_array=$_SESSION[$this->sessionName];
if($cur_cart_array!="")
{
$mode_goods_data=M("goods_data");
$len=count($cur_cart_array);
for($i=0;$i<$len;$i++)
{
$goodsid=$cur_cart_array[$i]["id"];
$num=$cur_cart_array[$i]["num"];
$query="select(selectsfilenamefromgoods_picwheregoodsid=a.goodsidorderbysnodesclimit0,1)assfilename,b.clsnameasclsname,a.goodsidasgoodsid,a.goodsnameasgoodsname,a.PriceasPrice,a._dataaleftjoingoods_clsbona.Clsid=b.clsidwherea.goodsid=$goodsid";
$list=$mode_goods_data->query($query);
$list[0]["qty"]=$num;
$list[0]["amount"]=$num*$list[0]["Price"];
$cartList[$i]=$list[0];
$totalPrice+=$list[0]["amount"];
}
//返回商品總價格
$this->totalPrice=$totalPrice;
return$cartList;
}
}
//加入購物車,購物車的商品id和購物車的商品數量
publicfunctionaddcart($goods_id,$goods_num){
$cur_cart_array=$_SESSION[$this->sessionName];
if($cur_cart_array=="")
{
$cart_info[0]["id"]=$goods_id;//商品id保存到二維數組中
$cart_info[0]["num"]=$goods_num;//商品數量保存到二維數組中
$_SESSION[$this->sessionName]=$cart_info;
}
else
{
//返回數組鍵名倒序取最大
$ar_keys=array_keys($cur_cart_array);
$len=count($ar_keys);
$max_array_keyid=$ar_keys[$len-1]+1;
//遍歷當前的購物車數組
//遍歷每個商品信息數組的0值,如果鍵值為0且貨號相同則購物車該商品已經添加
$is_exist=$this->isexist($goods_id,$goods_num,$cur_cart_array);
if($is_exist==false)
{
$cur_cart_array[$max_array_keyid]["id"]=$goods_id;
$cur_cart_array[$max_array_keyid]["num"]=$goods_num;
$_SESSION[$this->sessionName]=$cur_cart_array;
}
else
{
$arr_exist=explode("/",$is_exist);
$id=$arr_exist[0];
$num=$arr_exist[1];
$cur_cart_array[$id]["num"]=$num;
$_SESSION[$this->sessionName]=$cur_cart_array;
}
}
}
//判斷購物車是否存在相同商品
publicfunctionisexist($id,$num,$array)
{
$isexist=false;
foreach($arrayas$key1=>$value)
{
foreach($valueas$key=>$arrayid)
{
if($key=="id"&&$arrayid==$id)
{
$num=$value["num"]+$num;
$isexist=$key1."/".$num;
}
}
}
return$isexist;
}
thinkphp開發使得我們比較容易的去進行了
//從購物車刪除
publicfunctiondelcart($goods_array_id){
//回復序列化的數組
$cur_goods_array=$_SESSION[$this->sessionName];
//刪除該商品在數組中的位置
unset($cur_goods_array[$goods_array_id]);
$_SESSION[$this->sessionName]=$cur_cart_array;
//使數組序列化完整的保存到cookie中
}
//清空購物車
publicfunctionemptycart(){
$_SESSION[$this->sessionName]="";
}
//修改購物車貨品數量
publicfunctionupdate_cart($up_id,$up_num){
//回復序列化的數組
$cur_goods_array=$_SESSION[$this->sessionName];
$cur_goods_array[$up_id]["num"]=$up_num;
$_SESSION[$this->sessionName]=$cur_cart_array;
}
}
?>
㈧ 求一個JS代碼,就APP購物車的代碼,可以在html直接實現的
給樓主做了一個,JS實現商品計數的加和減,最少不能少於1,最多不大於99,代碼裡面有注釋,方面樓主查看和使用。
㈨ 求商城購物車具體代碼,HTML5+CSS+php的,有沒有大神具體給一下或者思路
packagecom.xxx.service.impl;
importjava.sql.SQLException;
importjava.util.ArrayList;
importjava.util.List;
importcom.xxx..CartDAO;
importcom.xxx..impl.JdbcCartDAO;
importcom.xxx.entity.CartItem;
importcom.xxx.entity.Proct;
importcom.xxx.service.CartService;
{
List<CartItem>items=newArrayList<CartItem>();
//增加商品
publicbooleanadd(intid)throwsSQLException{
for(CartItemitem:items){
if(item.getPro().getId()==id){
//判斷是否購買過
if(item.isBuy()){
item.setQty(item.getQty()+1);
returntrue;
}
}
returnfalse;//資料庫出現錯誤,沒有該商品
}
CartItemitem=newCartItem();
CartDAO=newJdbcCartDAO();
Proctpro=.findById(id);
item.setPro(pro);
item.setQty(1);
item.setBuy(true);
returntrue;
}
//刪除商品
publicvoiddelete(intid)throwsSQLException{
for(CartItemitem:items){
if(item.getPro().getId()==id){
item.setBuy(false);
}
}
}
//恢復刪除的商品
publicvoidrecovery(intid)throwsSQLException{
for(CartItemitem:items){
if(item.getPro().getId()==id){
item.setBuy(true);
}
}
}
//更新商品數量
publicvoipdate(intid,intpnum)throwsSQLException{
for(CartItemitem:items){
if(item.getPro().getId()==id){
if(item.getQty()==0){
delete(id);
}else{
item.setQty(pnum);
}
}
}
}
//獲取購買過的商品
publicList<CartItem>getBuyPros()throwsSQLException{
List<CartItem>list=newArrayList<CartItem>();
for(CartItemitem:items){
if(item.isBuy()){
list.add(item);
}
}
if(list.size()>0){
returnlist;
}
returnnull;
}
//獲取已經刪除的商品(可以恢復)
publicList<CartItem>getDelPros()throwsSQLException{
List<CartItem>list=newArrayList<CartItem>();
for(CartItemitem:items){
if(!item.isBuy()){
list.add(item);
}
}
if(list.size()>0){
returnlist;
}
returnnull;
}
//商品消費總額
publicdoublecost()throwsSQLException{
doubletotal=0;
for(CartItemitem:items){
if(item.isBuy()){
total+=item.getQty()*item.getPro().getPrice();
}
}
returntotal;
}
//清空購物車
publicvoidclear()throwsException{
items.clear();
}
}
㈩ dreamweaver編寫購物車的問題(ASP)
set RsList = server.CreateObject("adodb.recordset")
SqlList = "SELECT * FROM ["&Datatable&"] where Proct_Id =bookid"
RsList.open SqlList, objConn, 1, 3
if not RsList.eof ant not RsList.bof then
response.write("在表中!內")
RsList.("ddd")=ddd
else
RsList.addnew
response.write("不在容表中!")
RsList.("ddd")=ddd
end if
RsList.close