Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./assets/css/main.css">
    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Lobster&family=Open+Sans&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <title>Fashion-Seller page</title>
</head>
<body>
    <header class="header cs">
        <a href="index.html" class="brandName">Fashion</a>
        <div class="search-container">
         <form >
           <input type="text" placeholder="Search.." name="search">
           <button type="submit"><i class="fa fa-search"></i></button>
         </form>
        </div>
        <a href="customer.html" id="customerbtn">Customer</a>
        <a href="seller.html" id="sellerbtn">Seller</a>
    </header>
    <div class="main_products">
        <button class="add_product" id="addProductBtn">Add your Product</button>
    </div>
    <div id="cart-products">
    </div>
    <div class="form">
        <form>  
            <div>
             <input id="id" type="hidden" name="id" />
            </div> <br>
              <div class="all">
                 <label class="" for="name" id="name-label">Name of the product:</label> <input id="name" placeholder="Glory dress" required="" type="words">
            </div>
            <br>
      
            <div class="all">
              <label class="" for="email" id="detail-label">Details:</label> <input  id="detail" name="detail" placeholder="This is an elegant dress made of cotton" required="" type="detail">
            </div>
            <br>
            <div class="all">
              <label class="" for="price" id="price-label">Price :</label> <input id="number"  placeholder="price in dollar $$" required="" type="number">
            </div>
            <br>
            <div>
               <label for="url">Image  Url : </label> <input id="image-url" placeholder="put the url of the image of your product here" type="url">
            </div>
            <br>
            <div class="all">
              <label for="Category" id="category-label">Category:</label> <select id="dropdown">
                <option disabled selected value="">
                  Select a cetagory..
                </option>
                <option>
                Sports
                </option>
                <option>
                Women
                </option>
                <option>
                Men
                </option>
                <option>
                Shoes
                </option>
                <option>
                Makeup 
                </option>
                <option>
                    Jewellery 
                </option>
                <option>
                    clothes
                </option>
              </select>
            </div>
             <div class="buttons">
              <button id="cancel">Cancel</button>
              <button id="submit">Add</button>
            </div>
          </form>
    </div>
     <script src="./assets/js/seller.js"></script>
</body>
</html>
              
            
!

CSS

              
                /* seller-view */
.main_products {
margin-top: 100px;
margin-left: 500px;
}
#addProductBtn {
    font-size: 50px;
    color: black;
    cursor: pointer;
}
#addProductBtn:hover {
    background-color: #8C464C ;
    color:white;
}    
/* Styling form page */
  input[type=words], select, textarea {
    width: 20%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
  }
  input[type=number] {
    width: 20%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
  }
  input[type=detail] {
    width: 70%;
    padding: 30px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
  }
  input[type=url] {
    width: 20%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
  }
.buttons {
 position: relative;
}
#submit {
    background-color: #4CAF50;
    color: white;
    padding: 12px 20px;
    margin-top: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    float: right;
    margin-right: 20px;
    font-size: 20px;
  }
#cancel {
    background-color: red;
    color: white;
    padding: 12px 20px;
    margin-top: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    float: right;
    font-size: 20px;
}
.add {
    font-size: 30px;
}
.form {
    border: 2px solid black;
    background-color: #cdcdcdcd;
    padding: 20px;
    font-family: cursive;
    font-size: 15px;
    height: 400px;
}
              
            
!

JS

              
                let storedProducts = JSON.parse(localStorage.getItem("products"));
let cartItem = storedProducts ? storedProducts : [];
let productWrapper = document.getElementById("cart-products");
let products= storedProducts ? storedProducts : [];
let idKey=0; 
if (!products.length) {
    idKey = 1;
} else {
    let lastItem = products[products.length - 1];
    idKey = Number(lastItem.id) + 1;
}
function createCart(products){
    productWrapper.innerHTML = "";
    products.forEach(function(product){
        let card = document.createElement("div");
        let cardHeaderInfo = document.createElement("div");
        let productImage = document.createElement("img");
        productImage.src = product.URL;
        let productPrice = document.createElement("h3");
        productPrice.textContent = product.price;
        let productCategory = document.createElement("h3");
        productCategory.textContent = product.category;
        let productName = document.createElement("h2");
        productName.textContent = product.name;
        let dolarsign = document.createElement("span");
        dolarsign.textContent = ' $';
        let productDetail = document.createElement("p");
        productDetail.textContent = product.detail;
        let deleteIcon= document.createElement("button");
        deleteIcon.innerHTML = '<i class="fa fa-trash"></i>' ;


        cardHeaderInfo.appendChild(productImage);
        cardHeaderInfo.appendChild(productCategory);
        productPrice.appendChild(dolarsign);
        cardHeaderInfo.appendChild(productPrice);
        card.appendChild(cardHeaderInfo);
        card.appendChild(productName);
        card.appendChild(productDetail);
        productWrapper.appendChild(card);
        cardHeaderInfo.appendChild(deleteIcon);

        card.className = 'cardItem';
        cardHeaderInfo.className = 'cardHeaderInfo';
        productImage.className = 'cardImg';
        productCategory.className = 'cardCategory';
        productPrice.className = 'cardPrice';
        productName.className = 'cardName';
        productDetail.className= 'cardDetail';
        deleteIcon.className = "productDelete";
    });
}
createCart(products);

// this function makes the seller add the products
    document.getElementById("submit").addEventListener("click", function(event){
        event.preventDefault();
        let productName=document.getElementById("name").value.trim();
        let productDetail=document.getElementById("detail").value.trim();
        let productPrice =document.getElementById("number").value.trim();
        let  ImageUrl= document.getElementById("image-url").value.trim();
        let  categoryOfProduct = document.getElementById("dropdown").value.trim();
        let idValue = document.getElementById("id");       
         if(productName === ""){
            alert("Please Enter the name of the product");
        }
        else if( productDetail === ""){
            alert("Please Enter the details  of the product");
        }
        else if(productPrice === ""){
            alert("Please Enter the price of the product");
        }
        else if(ImageUrl === ""){
            alert("Please Enter the Image of the product");
        }
        else if (categoryOfProduct === "") {
            alert ("Please select the category of the product");
        }
        else {
            products.push( {id: idKey, name: productName, price:productPrice, detail: productDetail, image:ImageUrl, category: categoryOfProduct });
            document.getElementById("name").value=""; 
            document.getElementById("detail").value="";
            document.getElementById("number").value="";
            document.getElementById("image-url").value= "";
            document.getElementById("dropdown").value="",
            createCart(products); 
        }
    });
  
    deleteIcon.addEventListener("click", function () {
        let confirmationResults = confirm(
          "Are you sure you want to delete this product"
        );
  
        if (confirmationResults) {
          products.splice(i, 1);
          createCart();
        }
      });
              
            
!
999px

Console