Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. $(document).ready(function(){
  3.    
  4.     $(".menu").siblings().hide();
  5.     $("#submit").show();
  6.  
  7.     //$("input[type='submit']").show();
  8.     //$("input[type='file']").show();
  9.     $("#gallery").show();
  10.     //$('.menu, .submenu, .scarpe').val('select');
  11.  
  12.     $(".menu, .submenu1, .submenu2, .misure_magliette").on("change", function(){
  13.         val = $(this).val();
  14.         console.log(val);
  15.         $("."+val).show();
  16.    
  17.    
  18.         console.log($(this).attr("class"));
  19.         if($(this).attr("class") == "menu"){
  20.        
  21.             $("."+val).show();
  22.  
  23.             $("."+val).siblings().hide();
  24.             $("#submit").show();
  25.             $(".menu").show();
  26.             console.log("ok")
  27.  
  28.  
  29.         }
  30.  
  31.         if($(this).attr("class") == "submenu1" || $(this).attr("class") == "submenu2"){
  32.             $("#gallery").show();
  33.  
  34.         }
  35.  
  36.  
  37.         //    $("."+val).val('select');
  38.         //    $("."+val).siblings().hide();
  39.  
  40.     });
  41.  
  42.  
  43.     $("input[type='number']").mouseout(function(){
  44.         console.log($(this).val());
  45.     })
  46.  
  47.     $("input[type='submit']").mouseover(function(){
  48.  
  49.     })
  50.  
  51.  
  52.     //var fileInput = document.getElementById('file_input');
  53.     //fileInput = $(".file_input");
  54.     cont =0;
  55.     rotate = 0;
  56. /*-----------------------------------------------------------------------------------*/
  57.  
  58.  
  59.     fileInput = document.getElementsByClassName("file_input");
  60.  
  61.     function main(){
  62.  
  63.     fileInput[cont].addEventListener("change", ()=>{
  64.  
  65.  
  66.     //    $(".file_input").eq(cont).on("change", () => {
  67.         //cont++;
  68.         //rotate -= 90;
  69.  
  70.  
  71.         div = document.createElement("div");
  72.  
  73.         for(let file of fileInput[cont].files) {
  74.             var image = file
  75.             if (image) {
  76.                 var imageElement = new Image();
  77.                 imageElement.src = URL.createObjectURL(image);
  78.                 imageElement.width = 100;
  79.        
  80.  
  81.                 var imageElement2 = new Image();
  82.                 imageElement2.src = "https://img.icons8.com/material-two-tone/24/000000/rotate-left.png";
  83.  
  84.                 //imageElement2.width = 100;
  85.  
  86.                 var imageElement3 = new Image();
  87.                 imageElement3.src="https://img.icons8.com/material-rounded/24/000000/rotate-right.png";
  88.      
  89.                 var imageElement4 = new Image();
  90.                 imageElement4.src="https://img.icons8.com/material-two-tone/24/000000/remove-image.png";
  91.  
  92.                 document.getElementById('gallery').appendChild(div);
  93.                 div.appendChild(imageElement2);
  94.  
  95.                 div.appendChild(imageElement3);
  96.                 div.appendChild(imageElement4);
  97.                 div.appendChild(imageElement);
  98.  
  99.                 $(imageElement2).click(function(){
  100.                     rotate = rotate - 90;
  101.                     //    rrotate = rotate + 90;
  102.  
  103.  
  104.                     console.log(7)
  105.                     $(imageElement).css("transform", "rotate("+rotate+"deg)");
  106.                     // $(imageElement).css("transform", "rotate("+lrotate+"deg)");
  107.  
  108.                 });
  109.  
  110.                 $(imageElement3).click(function(){
  111.                     // lrotate = rotate - 90;
  112.                     rotate = rotate + 90;
  113.  
  114.  
  115.                     console.log(7)
  116.                     // $(imageElement).css("transform", "rotate("+lrotate+"deg)");
  117.                     $(imageElement).css("transform", "rotate("+rotate+"deg)");
  118.  
  119.                 });
  120.  
  121.                 $(imageElement4).click(()=>{
  122.                     $(imageElement).css("display","none");
  123.                 })
  124.  
  125.  
  126.             }
  127.         }
  128.         $("img").click(function(){
  129.             console.log(4);
  130.         })
  131.         console.log(cont)
  132.     cont++
  133.     console.log(cont)
  134.  
  135.     });
  136.  
  137.     }
  138.     //cont=0;
  139.     $("#addimg").click(()=>{
  140.         //  cont++
  141.         $(".file_input").eq(cont).click();
  142.         main();
  143.     })
  144.  
  145.  
  146. form = document.forms[0];
  147.  
  148. botonSubmit = document.getElementById("submit");
  149. botonSubmit.addEventListener("click", (e)=>{
  150.     e.preventDefault();
  151.     dati = new FormData(form);
  152.  //   console.log(dati.get("product"));
  153.  
  154.     if(dati.get("product") == "scarpe"){
  155.         console.log(dati.get("product"));
  156.  
  157.         console.log(dati.get("scarpe_genere"));
  158.         console.log(dati.get("scarpe_num"));
  159.  
  160.  
  161.     }
  162.     else if(dati.get("product")=="magliette"){
  163.         console.log(dati.get("product"));
  164.        
  165.         console.log(dati.get("sesso_magliette"));
  166.  
  167.         console.log(dati.get("misure_magliette"));
  168.  
  169.  
  170.     }
  171.  
  172.     fetch("output2.php", {
  173.         method:'POST',
  174.         body: dati
  175.     })
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183. })
  184.  
  185.  
  186.  
  187.  
  188. })
  189.  
  190.  
  191.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement