Multiple textareas into one text file

I wanted to ask how can I write multile text areas into a html and then connect them into the javascript, because I was able just to connect one. My idea is that the first text area will be for one information and the second for another. This information will be than combine in the text file that the website will export.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="./style.css"/>
<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="js/FileSaver.js"></script>
</head>
<body>

</body>
</html>
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="js/FileSaver.js"></script>
    <script>

        function saveDynamicDataToFile() {

            var userInput = document.getElementById("myText").value;
            
            var blob = new Blob([userInput], { type: "text/plain;charset=utf-8" });
            saveAs(blob, "code.txt");
        }

    </script>
</head>
<body>

    <header>
        <button type="button" class="BuyBtn2" style="background-color: blueviolet; margin-right: 40px;" onclick="saveDynamicDataToFile();">Click to Save</button>
    </header>

    <textarea id="myText" hidden></textarea>
    <textarea id="myText" hidden></textarea>
</body>
</html>

plus here is the FileSaver file 

    /*
    * FileSaver.js
    * A saveAs() FileSaver implementation.
    *
    * By Eli Grey, http://eligrey.com
    *
    * License : https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md (MIT)
    * source  : http://purl.eligrey.com/github/FileSaver.js
    */
    
    // The one and only way of getting global scope in all environments
    // https://stackoverflow.com/q/3277182/1008999
    var _global = typeof window === 'object' && window.window === window
      ? window : typeof self === 'object' && self.self === self
      ? self : typeof global === 'object' && global.global === global
      ? global
      : this
    
    function bom (blob, opts) {
      if (typeof opts === 'undefined') opts = { autoBom: false }
      else if (typeof opts !== 'object') {
        console.warn('Deprecated: Expected third argument to be a object')
        opts = { autoBom: !opts }
      }
    
      // prepend BOM for UTF-8 XML and text/* types (including HTML)
      // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
      if (opts.autoBom && /^s*(?:text/S*|application/xml|S*/S*+xml)s*;.*charsets*=s*utf-8/i.test(blob.type)) {
        return new Blob([String.fromCharCode(0xFEFF), blob], { type: blob.type })
      }
      return blob
    }
    
    function download (url, name, opts) {
      var xhr = new XMLHttpRequest()
      xhr.open('GET', url)
      xhr.responseType = 'blob'
      xhr.onload = function () {
        saveAs(xhr.response, name, opts)
      }
      xhr.onerror = function () {
        console.error('could not download file')
      }
      xhr.send()
    }
    
    function corsEnabled (url) {
      var xhr = new XMLHttpRequest()
      // use sync to avoid popup blocker
      xhr.open('HEAD', url, false)
      try {
        xhr.send()
      } catch (e) {}
      return xhr.status >= 200 && xhr.status <= 299
    }
    
    // `a.click()` doesn't work for all browsers (#465)
    function click (node) {
      try {
        node.dispatchEvent(new MouseEvent('click'))
      } catch (e) {
        var evt = document.createEvent('MouseEvents')
        evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80,
                              20, false, false, false, false, 0, null)
        node.dispatchEvent(evt)
      }
    }
    
    // Detect WebView inside a native macOS app by ruling out all browsers
    // We just need to check for 'Safari' because all other browsers (besides Firefox) include that too
    // https://www.whatismybrowser.com/guides/the-latest-user-agent/macos
    var isMacOSWebView = _global.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent)
    
    var saveAs = _global.saveAs || (
      // probably in some web worker
      (typeof window !== 'object' || window !== _global)
        ? function saveAs () { /* noop */ }
    
      // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView
      : ('download' in HTMLAnchorElement.prototype && !isMacOSWebView)
      ? function saveAs (blob, name, opts) {
        var URL = _global.URL || _global.webkitURL
        var a = document.createElement('a')
        name = name || blob.name || 'download'
    
        a.download = name
        a.rel = 'noopener' // tabnabbing
    
        // TODO: detect chrome extensions & packaged apps
        // a.target = '_blank'
    
        if (typeof blob === 'string') {
          // Support regular links
          a.href = blob
          if (a.origin !== location.origin) {
            corsEnabled(a.href)
              ? download(blob, name, opts)
              : click(a, a.target = '_blank')
          } else {
            click(a)
          }
        } else {
          // Support blobs
          a.href = URL.createObjectURL(blob)
          setTimeout(function () { URL.revokeObjectURL(a.href) }, 4E4) // 40s
          setTimeout(function () { click(a) }, 0)
        }
      }
    
      // Use msSaveOrOpenBlob as a second approach
      : 'msSaveOrOpenBlob' in navigator
      ? function saveAs (blob, name, opts) {
        name = name || blob.name || 'download'
    
        if (typeof blob === 'string') {
          if (corsEnabled(blob)) {
            download(blob, name, opts)
          } else {
            var a = document.createElement('a')
            a.href = blob
            a.target = '_blank'
            setTimeout(function () { click(a) })
          }
        } else {
          navigator.msSaveOrOpenBlob(bom(blob, opts), name)
        }
      }
    
      // Fallback to using FileReader and a popup
      : function saveAs (blob, name, opts, popup) {
        // Open a popup immediately do go around popup blocker
        // Mostly only available on user interaction and the fileReader is async so...
        popup = popup || open('', '_blank')
        if (popup) {
          popup.document.title =
          popup.document.body.innerText = 'downloading...'
        }
    
        if (typeof blob === 'string') return download(blob, name, opts)
    
        var force = blob.type === 'application/octet-stream'
        var isSafari = /constructor/i.test(_global.HTMLElement) || _global.safari
        var isChromeIOS = /CriOS/[d]+/.test(navigator.userAgent)
    
        if ((isChromeIOS || (force && isSafari) || isMacOSWebView) && typeof FileReader !== 'undefined') {
          // Safari doesn't allow downloading of blob URLs
          var reader = new FileReader()
          reader.onloadend = function () {
            var url = reader.result
            url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;')
            if (popup) popup.location.href = url
            else location = url
            popup = null // reverse-tabnabbing #460
          }
          reader.readAsDataURL(blob)
        } else {
          var URL = _global.URL || _global.webkitURL
          var url = URL.createObjectURL(blob)
          if (popup) popup.location = url
          else location.href = url
          popup = null // reverse-tabnabbing #460
          setTimeout(function () { URL.revokeObjectURL(url) }, 4E4) // 40s
        }
      }
    )
    
    _global.saveAs = saveAs.saveAs = saveAs
    
    if (typeof module !== 'undefined') {
      module.exports = saveAs;
    }

Strapi Error Not Logical: Getting ‘An error occurred during account creation’ instead of ‘Username already taken’ when a existing username is used

I am using Strapi within my Next.js website.

Within my Strapi I have a Collection-Type of User
and a User has a username, email, password

username should be unique
email should be unique

When I purposefully use a existing email in the system to register it does return an error of ‘Email is already taken’

Then if I fill out the email with a unique email and have the password and confirm password filled up the but the username BLANK I get ‘Username already taken’

However if I enter a username that is already taken and already in the Strapi system, and then a unique email and then have the password and confirm password filled in with the same value so that they match I do not get ‘Username already taken’ which I want….what I get instead is ‘An error occurred during account creation’

What is the reason for this and how do I fix this?
I want the error to say Username already taken because that is the reason why the registration cannot proceed. That way the person signing up can fix the problem instead of thinking it is the system the system that is not programmed properly….

Pass file through ajax with nodejs

    const editProductBody = document.querySelector('#update-product-modal .modal-body')
    $.get({
        url: '/admin/product/detail/' + productId,
        contentType: 'multipart/form-data',
        success: function(response) {
            editProductBody.innerHTML = `
                <form action="/admin/product/update/${response._id}?_method=PUT" method="POST">
                    <label for="">Product name<span style="color: red;">*</span></label> <br>
                    <input type="text" name="name" value="${response.name}"><br>
                    <label for="">Price<span style="color: red;">*</span></label> <br>
                    <input type="text" name="price" value="${response.price}"><br>

                    <label for="">Pictures<span style="color: red;">*</span></label> <br>
                    <div class="row">
                        <div class="col-sm-9 ml-auto">
                            <img src="${response.photo[0]}"> <br>
                            <img src="${response.photo[1]}"> <br>
                        </div>
                        <div class="col-sm-3 ml-auto"> 
                            <input type="file" class="form-control" name="image1" id="image1">
                            <input type="file" class="form-control" name="image2" id="image2">
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                        <button id="btn-update-product" class="btn btn-primary">Update</button>
                    </div>
                </form>`
        }
    })

When I req.body, it has image1, image2 but I want to transfer them as files to process with cloudinary. How can I fix it ?

HTML element passing first value in PHP array to Ajax

I have an HTML that gets its values from an array list. I’m submitting the form with Ajax and with a PHP script. The issue I’m facing is when clicking on the other array it only submits the first value array. Below is what my form looks like with the PHP loop of array listing:

index.php


       
$query_product = "SELECT * FROM products ORDER BY id DESC";
$product_stmt = $conn->prepare($query_product);


if($product_stmt->execute()){
    while($row_product = $product_stmt->fetch(PDO::FETCH_ASSOC)){
    
    $id = $row_product["id"];
    $title = $row_product["title"];
    $description = $row_product["description"];
    $price = $row_product["price"];
    $img = $row_product["img"];
    
  
                         ?>

 <form onsubmit="clickButton()">
   <input type="hidden" value="<? echo $title ?>" name = "title" id="title" >
   <input type="hidden" value="<? echo $id ?>" name = "id" id="id" >
   <input type="hidden" value="<? echo $price; ?>" name="price" id="price">
  <input type="hidden" value="<? echo $img; ?>" name="img_src" id="img_src">
 <button type="submit" id="add_to_cart" name="add_to_cart" class="btn btn-outline-secondary btn-sm" value="Add to cart" onclick="return clickButton();">Add Cart</button>
</form>

<?php 
     }
  }


?>
                       

My Ajax looks like the below:


<script type="text/javascript">

function clickButton(){
   
     var title = $("#title").val();
 var price = $("#price").val();
 var img_src = $("#img_src").val();
 var id = $("#id").val();
    
alert(title);

      $("#add_to_cart").attr("disabled", true);
      
    $.ajax({
        type:"post",
        url:"my_add_cart.php",
        data: 
        {  
           'title' :title,
           'price' :price,
           'img_src' :img_src,
            'id' :id
        },
        cache:false,
        
         beforeSend: function(){
     $("#loading").show();
   },
   
   complete: function(){
     $("#loading").hide();
   },
   
 success: function (data) 
        {
         //   alert(data['message']);
          //enable loading 
             $("#add_to_cart").attr("disabled", false);
          
           $('#msg').html(data['message']);
           $('#count').html(data['count']);        
        }
        
    });
    return false;
 }
</script>



When I tried to alert(title); above it return just the first array value even though I click the other arrays.

How to get the autocomplete query in discord.js

Recently, I came to know about the Autocomplete feature in [email protected] and I wanted to try it out. I was able to do the basics by seeing the answer on this post => How to use AutoComplete in Discord.js v13

I was able to set up the autucomplete and was also able to respond to the autocomplete interaction by using:

client.on('interactionCreate', interaction => {
   if (interaction.isAutocomplete()) {
      interaction.respond([
         {
            name: 'Command Help',
            value: 'help'
         }
      ]);      
   }
})

But my doubt is that is there any way to get the string which the user typed which caused the autocomplete interaction. For example: there is an array of options, and based on what the user typed, I would be able to filter the options and then show the correct ones?

Do I have a problem with my javascript or is it something else?

(I would like to adress that English is not my first language)
I have this problem with javascript for a very long time and I don’t know what to do.
This javascript is for a registration. Sometimes it gives access even though I haven’t typed everything, or it doesn’t give access even though I have typed everything correctly
If someone can help thanks already!

function validateform() {
    var res = true;
    res = userNameVal() && res;
    res = passowrdVal() && res;
    res = ConfirmPhone() && res;
    res = emailConfirm() && res;
    res = Name() && res;
    res = lastName() && res;
    res = city() && res;
    return res;
}


function Name() {
    var firstName = document.getElementById("firstName").value;
    var msgBox = document.getElementById("NameMsg");
    if (firstName.length == 0) {
        msgBox.innerHTML = "You must enter your name";
        return false;
    }
    var reg = /[0-9]/;
    var reg1 = /w/;
    var reg2 = /s/;
    if (reg.test(firstName) && reg1.test(firstName) && reg2.test(firstName) && (English(firstName))) {
        msgBox.innerHTML = "Your name can't have a number, space or a special char";
        return false;
    }
    msgBox.innerHTML = "";
    return true;
} 
function lastName() {
    var LastName = document.getElementById("LastName").value;
    var msgBox = document.getElementById("LastNameMsg");
    var reg = /[0-9]/;
    var reg1 = /w/;
    var reg2 = /s/;
    if (Name.length == 0) {
        msgBox.innerHTML = "You must enter your name";
        return false;
    }
    if (reg.test(LastName) || reg1.test(LastName) || reg2.test(LastName)) {
        msgBox.innerHTML = "Your name can't have a number, space or a special char";
        return false;
    }
    msgBox.innerHTML = "";
    return true;
} 
    function city() {
        var CityName = document.getElementById("CityName").value;
        var msgBox = document.getElementById("CityNameMsg");
        var reg = /[0-9]/;
        var reg1 = /w/;
        var reg2 = /s/;
        if (CityName.length == 0) {
            msgBox.innerHTML = "You must enter your City";
            return false;
        }
        if (reg.test(CityName) || reg1.test(CityName) || reg2.test(CityName)) {
            msgBox.innerHTML = "Your name can't have a number, space or a special char";
            return false;
        }
        
        msgBox.innerHTML = "";
        return true;
    }

    function userNameVal() {
        var userName = document.getElementById("userName").value;
        var msgBox = document.getElementById("userNameMsg");
        if (userName.length == 0) {
            msgBox.innerHTML = "You must enter a username";
            return false;
        }
        if (!isLetter(userName[0])) {
            msgBox.innerHTML = "Your username must start with a letter";
            return false;
        }
        msgBox.innerHTML = "";
        return true;
    }



    function passowrdVal() {
        var pass = document.getElementById("password").value;
        var msgBox = document.getElementById("passwordMsg");
        var specialChar = /[@!#$%^&*()-+]/;
        if (pass.length == 0) {
            msgBox = "You must enter a password";
            return false;
        }
        if (pass.length < 7) {
            msgBox.innerHTML = "The password must contain at least 7 charactes"
            return false;
        }
        
        if (!specialChar.test(pass)) {
            msgBox.innerHTML = "password must contain one special letter ";
            return false;
        }
        msgBox.innerHTML = "";
        return true;
    }



    function ConfirmPhone() {
        var phone = document.getElementById("phone").value;
        var msgBox = document.getElementById("phoneMsg");
        var reg = /^0{1}(2|3|4|6|8|9|5[0|[2-8]|73)-?[1-9]d{6}$/;
        if (!reg.test(phone)) {
            msgBox.innerHTML = "Phone number is illegal";
            return false;
        }
        msgBox.innerHTML = "";
        return true;
    }


function emailConfirm() {
    var email = document.getElementById("email").value;
    var msgBox = document.getElementById("emailMsg");
    var reg = /^w+/;
    if (!reg.text(email)) {
        msgBox.innerHTML = "Mail can hava only one following letter";
        return false;
    }
    msgBox.innerHTML = "";
    reg = /^w+([.-]?w+)*@w+/;
    if (!reg.test(email)) { 
        msgBox.innerHTML = "Mail must have @";
        return false;
}

        reg = /^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,4})+$/;
        if (!reg.test(email)) {
            msgBox.innerHTML = "invalid email";
            return false;
        }
        msgBox.innerHTML = "";
        return true;
    }

function isLetter(ch) {
        if ((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z"))
            return true;
        return false;
}

function isDigit(ch) {

    if (ch >= "0" && ch <= "9")
        true;
    false;

}
function English(str) {
    i = 0;
    while (str[i].isLetter) {
        i++;
    }
    if (i == str.length())
        return true;
    return false;

}

Photoshop script: output name of every selected top-level layer?

I’ve got an ActionReference Photoshop Javascript code working here that spits out the name of every selected layer:

var lyrs = [];
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
var targetLayers = executeActionGet(ref).getList(stringIDToTypeID('targetLayers'));
for (var i = 0; i < targetLayers.count; i++) {
    var ref2 = new ActionReference();
    ref2.putIndex(charIDToTypeID('Lyr '), targetLayers.getReference(i).getIndex() + 1);
    var desc = executeActionGet(ref2);
    lyrs.push(desc.getString(charIDToTypeID('Nm  ')));
}
lyrs.join('\n');

(I join these into a single line-delimited string at the end for use in AppleScript, so ignore that part for now).

However, this code also includes the nested layers as well (this happens when you shift-click groups of layer sets), and I’m not sure how to modify this code to ignore those lower level nested layers, and only output the list of the top-level layer names.

I’m very experienced with AppleScript, but I’m a novice at JavaScript, so go easy on me!

javascript cant read my toggle please help me with it

When I try To Function The Hamburger using the code Please help

burger = document.querySelector('.burger')
navbar = document.querySelector('.navbar')
navlist = document.querySelector('.nav-list')


burger.addEventListener('click', ()=>{
navbar.ClassList.toggle('v-class-resp');
nav-list.classlist.toggle('v-class-resp');

})

It Show Me The Error Can’t read toggle (reading ‘toggle) if someone could help with design please help me

here is the html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="Home.css">
    
    <title>SG Network</title>
    
</head>
<body  >
    
    <nav class="navbar background h-nav-resp" >
        <ul class="nav-list v-class-resp">
            <div class="logo" style="border: 60px;"> <img src="Add a heading.jpg" alt="Logo"> </div>
            <li> <a href="#HomePage">HomePage</a></li>
            <li> <a href="#About us">About us</a></li>
            <li> <a href="#Buy-Ranks">Buy Ranks</a></li>
            <li> <a href="#Donate">Donate</a></li>
            <li> <a href="#Vote">Vote</a></li>
            <li> <a href="#Discord">Discord</a></li><h1></h1>
        </ul>
        <div class="burger">
            <div class="line"></div>
            <div class="line"></div>
            <div class="line"></div>
        </div>
    </nav>
    <section class="firstsection background">
<div class="box background">
<div class="firsthalf "> <p class="text-big">SG NetWork Is A Network blah blah blah blah blah vlah vlah
     vlah blah vlah vlah blah vlah vlah blah vlah vlah blah vlah vlah blah vlah vlah blah vlah
      vlah blah vlah vlah blah vlah vlah blah vlah vlah blah 

            
</p>
<div class="button">
    <button class="btn">Vote</button>
    <button class="btn">Discord</button>
</div>
 </div>
<div class="secondhalf ">

    
</div>
</div>

<p>
    <footer class="foot background">Copyright &copy; All Rights Reserverd</footer>
    </p>

    <script src="resp.js">
    </script>
</body>
</html>

help would be apprieciated
enter image description here

Please Help This Is the page

rerun animation whenever the element changes

I’m using React to Create an img element that changes its src attribute aftter specific time with setinterval function based on an array that contains many images.

so the thing is i want to make an animation whenever the src attribute changes, i was thinking of using React.useEffect() method to watch for the element of it’s changed and add some animation but i couldn’t go further logically.

my code :

import Canada from "../images/Canada.jpg"
import Tokyo from "../images/Tokyo.jpg"
import NewYork from "../images/NewYork.jpg"
import southKorea from "../images/southKorea.jpg"


function AboutMe() {

    const imgArray = [NewYork, Tokyo, Canada, southKorea]
     let i = 0;
    const maxImgArray = imgArray.length -1 ;
    const swap = function() {
        let image = imgArray[i];
        i = (i === maxImgArray) ? 0 : ++i;
        const attr = document.getElementById("moving-image");
        attr.src=image;
    }
    setInterval(swap, 5000)
    return (
    <section className="About-me">
        <h1>About me</h1>
        <div className="container">
        <div className="cities-images">
            <img 
            src={Tokyo}
            alt="NewYork" id="moving-image"></img>
            <label class="switch">
              <input type="checkbox"/>
              <span class="slider round"></span>
            </label>
        </div>
            <div className="info">
                
            </div>
        </div>
    </section>    
    )
}

sorry if i putted all my code

Modifying array in JavaScript using array method

let fruits = [‘apple’ , ‘cherry’, ‘grape’, undefined, ‘lemon’ ,’melon’];

i have those array of fruits.
i want to replace undefined with another fruit, 
and return all the array with new fruit included.
how to do that using array method in javascript
i do need help

How to render this array in array react js

Hi I want to show this advice from this api i have fetched all the data but when I try to show it it throws error and also I tried to map the data but nothing works it shows errors

import React, { useState, useEffect } from 'react';

export default function App() {
  const [advices, setAdvices] = useState([]);
  console.log(advices); // you should have the fetch data here

  async function fetchData() {
    try {
      const response = await fetch('https://api.adviceslip.com/advice');
      const data = await response.json();
      setAdvices(data.slip);
    } catch (error) {
      console.error(error);
    }
  }

  useEffect(() => {
    fetchData();
  }, []);

  return <></>;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

Href link is not linking properly

import React from "react";
import "./Cards.css";
import CardItem from "./CardItem";
import { Link } from "react-router-dom";

function Cards() {
  return (
    <div className="cards">
      <h1>Hello</h1>
      <div className="cards__container">
        <div className="cards__wrapper">
          <ul className="cards__items">
            <CardItem
              src="images/img-9.jpg"
              text="Hello"
              label="Warriors"
              path="/services"
            />
            <CardItem
              src="images/img-2.jpg"
              text="Hello"
              label="Disciples"
              path="/services"
            />
          </ul>
          <ul className="cards__items">
            <CardItem
              src="images/img-3.jpg"
              text="Hello"
              label="Degens"
              path="/services"
            />
            <CardItem
              src="images/img-4.jpg"
              text="Coming Soon"
              label="Coming Soon"
              path="/products"
            />
            <CardItem
              src="images/img-4.jpg"
              text="Coming Soon"
              label="Coming Soon"
              href="https://twitter.com/"
              target="_blank"
            />
          </ul>
        </div>
      </div>
    </div>
  );
}

export default Cards;

So I’m trying to use the href at the bottom to link to Twitter? When putting an atag I get an error. is there another function I can use?

Ps. what I’m trying to do is on my home page have a picture which when the user clicks on it redirects them to twitter.