JavaScript implementation of Shopping cart effects-effects buddy list

Source: Internet
Author: User

JavaScript implements the shopping cart effect, of course, which can be used in many places with this effect, friend. For example, in the selection, Human resources module. Salary calculation, talent selection, etc... Let's take a look at some cars after work:

Code

Goodscar.js: This JS is written in a separate file. The main control is shown in the list above.

Window.onload=function () {Initstore ();}; var goods=["Ham", "Beauty", "be", "Mars Day Trip", "sports car"];//================== Why should you define a temporary storage area to be clear oh =============var temps=[];//temporary storage// Initialize warehouse Select to add Content function Initstore () {var Select_store=document.getelementbyid ("Select_store"); for (Var x=0;x< goods.length;x++) {//Create option object var optionnode=document.createelement ("option"); optionnode.innerhtml=goods[x]; Select_store.appendchild (Optionnode);}} ------------------------------------function Selectgoods () {//Get the store's select list Object var out_store= document.getElementById ("Select_store");//Gets the select list object of my product var In_store=document.getelementbyid ("Select_my"); Movegoods (In_store,out_store);} function Deletegoods () {//1. Log the product to be moved var In_store=document.getelementbyid ("Select_store"); var out_store= document.getElementById ("Select_my"); Movegoods (In_store,out_store);} /* Mobile Goods: 1.inSotre: Move goods into warehouse 2.outStore: Move goods out of warehouse *///move function movegoods (instore,outstore) {//=============== empty array cache = = The ================temps=[];//loop gets all the list items in the store for (Var x=0;x<outstore.options.length;x++) {var option=outstore.options[x];//adds the selected list item to the temporary array to store if (option.selected) {temps.push (option); /temporarily add data to the array. To avoid repetition, the array cache is emptied}}//2. Remove the selected item//3 in the store list. Add the selected product for (Var x=0;x<temps.length;x++) in the shopping cart {//Each node has only one parent node// First delete and then add Outstore.removechild (Temps[x]);//Join Instore.appendchild (Temps[x]);}}


The following is the main file;

<! DOCTYPE html>


Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.

JavaScript implementation of Shopping cart effects-effects buddy list

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.