how I can print textarea in DOM properly? [duplicate]

I have a simply textarea, but when I submit a log text looks like this enter image description here

Doesn’t look like a paragraph, if I use the scroll option of bootstrap is a horizontal scroll not vertical. Is a js problem o css?, how I can fix it?

Honestly I didยดt tried much, I didn’t know this will happens ๐Ÿ™

Adding elements to array from JSON is returning empty array. How can I stop this?

I have a .JSON file, I’ve read the data and am using a for...in loop to loop through it.

If I use console.log, then I can print the data to the console, but if I try to add data to an array using the push function and console.log the array, I get an empty array.

Basically, how do I add the data to the array?

The code:

let wordList = []

fetch("wordleanswers.json")
    .then(response =>response.json())
    .then(data=>{
        let myWord = data.toString()

        for (const singleData in data){
            wordList.push(singleData)
        }
    })

console.log(wordList)

Is there something I’m missing?

Add Identifier to json response

I’m making a currency widget for my website and I’m using this github based free Api which provides currencies in JSON format.

i want to display 4 different currencies, but my problem is that, when my json is parsing information from these 4 different URL’s, every html element is just showing 1 currency number.

because json response doesnt have any identifier which i would use. Is there any way that i can assign identifiers manually or something like that? Thanks for help. Here is my full code.

    <div style="width: 175px;height: 72px;margin-top: -15px;">
<script>
var index = ["usd/gel.json", "eur/gel.json", "rub/gel.json", "gbp/gel.json"];
for (var i = 0; i < index.length; i++) {

    var link = "https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/" + index[i];

    let xmlHttp = new XMLHttpRequest();
    xmlHttp.open("GET", link);
    xmlHttp.onreadystatechange = function() {
        if(xmlHttp.readyState === XMLHttpRequest.DONE && xmlHttp.status === 200) {
            var data = JSON.parse(xmlHttp.responseText);
             document.getElementById('valuta-usd').innerHTML = JSON.parse(xmlHttp.responseText).gel;
     document.getElementById('valuta-eur').innerHTML = JSON.parse(xmlHttp.responseText).gel;
     document.getElementById('valuta-rub').innerHTML = JSON.parse(xmlHttp.responseText).gel;
     document.getElementById('valuta-gbp').innerHTML = JSON.parse(xmlHttp.responseText).gel;
            
            console.log(data);
        }
    }
    xmlHttp.send();
    
}    
</script>
<div id="valuta123">
<div style="display: inline-flex;">1 USD&nbsp;<img src="/templates/askinfov3/images/flags/usd.png" alt="USD" style="height: 16px;">&nbsp;=&nbsp;<div id="valuta-usd">แƒ˜แƒขแƒ•แƒ˜แƒ แƒ—แƒ”แƒ‘แƒ</div></div>
<div style="display: inline-flex;">1 EUR &nbsp;<img src="/templates/askinfov3/images/flags/eur.png" alt="EUR" style="height: 16px;">&nbsp;=&nbsp;<div id="valuta-eur">แƒ˜แƒขแƒ•แƒ˜แƒ แƒ—แƒ”แƒ‘แƒ</div></div>
<div style="display: inline-flex;">1 RUB &nbsp;<img src="/templates/askinfov3/images/flags/rub.png" alt="RUB" style="height: 16px;">&nbsp;=&nbsp;<div id="valuta-rub">แƒ˜แƒขแƒ•แƒ˜แƒ แƒ—แƒ”แƒ‘แƒ</div></div>
<div style="display: inline-flex;">1 GBP &nbsp;<img src="/templates/askinfov3/images/flags/gbp.png" alt="GBP" style="height: 16px;">&nbsp;=&nbsp;<div id="valuta-gbp">แƒ˜แƒขแƒ•แƒ˜แƒ แƒ—แƒ”แƒ‘แƒ</div></div>
</div>
 
    
    
    
</div>

How to change the Date format from data received

I’m creating a Github User Search app and I am currently getting the user data from the Github API. The date format of the user.created_at date shows as ‘2011-01-25T18:44:36Z’ How can I format this date to ‘Joined 25 January 2011’? I’m accessing / inserting the HTML through JS.

 <div class="profile-user-wrapper">
  <div class="profile-name">${user.name}</div>
  <div class="username">@${user.login}</div>
  <div class="join-date">${user.created_at}</div>
</div>

[Image of my app][1]
[1]: https://i.stack.imgur.com/Eb2Hp.png

Function assigned to a mousover event as undefined

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Php Free Chat</title>
    
    <style>
        body{background-color:orange}
        #CubeAside{
            box-sizing:border-box;border:3px solid green; position:absolute;top:14%;left:50%;height:88%;width:500px;background-color:black;color:green;
        }
    
        #initialCube{
            box-sizing:border-box;border:3px solid green; position:absolute;top:14%;left:50%;height:50px;width:50px;background-color:black;color:green;
            
        }
        
        #smallButtonBottomLeftInitialCube{box-sizing:border-box;border:3px solid green; position:absolute;top:101%;left:1%;height:18%;width:18%;background-color:black;color:green;font-size:1.4em}
        
        
        #penButton{box-sizing:border-box;border:3px solid green; position:absolute;top:-15%;left:50px;height:18%;width:18%;background-color:black;color:green;font-size:1.4em}
        #textButton{box-sizing:border-box;border:3px solid green; position:absolute;top:-15%;left:225px;;height:18%;width:18%;background-color:black;color:green;font-size:1.4em}
        #toolbar{box-sizing:border-box;border:3px solid green; position:absolute;top:5%;left:5%;height:250px;width:50px;background-color:yellow;color:green;}
        #cubeSelectionTool{box-sizing:border-box;border:3px solid green; position:absolute;top:1%;left:1%;height:50px;width:50px;background-color:yellow;color:green;}
        #cubeRotationTool{box-sizing:border-box;border:3px solid green; position:absolute;top:21%;left:1%;height:50px;width:50px;background-color:yellow;color:green;}
        #cubeScalingTool{box-sizing:border-box;border:3px solid green; position:absolute;top:42%;left:1%;height:50px;width:50px;background-color:yellow;color:green;}
        #cubeConnectingLineTool{box-sizing:border-box;border:3px solid green; position:absolute;top:63%;left:1%;height:50px;width:50px;background-color:yellow;color:green;}
        #cubeMagnificationTool{box-sizing:border-box;border:3px solid green; position:absolute;top:84%;left:1%;height:50px;width:50px;background-color:yellow;color:green;}
        
        
        
    </style>
</head>

<body>


</div>
<div id="phpFreeChatInterface">
<?php echo 'insertPhpFreeChat'?>    
</div>
    
<div id="CubeAside"><div id="text"><button id="textButton" onclick="addText()">Text</button></div>
<div id="pen"><button id="penButton" onclick="addPen()">Pen</button></div><div id="initialCube"><button onmouseover="checkMouseover()" onmouseout="checkMouseout()" id="smallButtonBottomLeftInitialCube" onClick="addThree()">_3</button></div>
<div id="toolbar">
<div id="cubeSelectionTool" onclick="cubeSelectionToolOn()">CST</div>
<div id="cubeRotationTool">789987</div>
<div id="cubeScalingTool">789987</div>
<div id="cubeConnectingLineTool">789987</div>
<div id="cubeMagnificationTool">789987</div>

</div></div>
<table><tr><a href="index.php">Ready Set Everest</a></tr></table>   

<script>
var aascNodeList; 
var beta = 0;   
var initializeCube;
var addThreeCubes;
var substractLastThreeCubesAdded;
var cubeCounter=0;
var cubeCounter02=0;
var allCubesAdded;
var allCubesAdded02;
var allCubesAddedInterval;
var intervalOne;    
var cubeWriting;
var cubeDrawing;    
    
    
    
    
function cubeSelectionToolOn(){
    document.getElementById('cubeSelectionTool').style.boxShadow='5px 5px gray';document.getElementById('cubeSelectionTool').setAttribute('onclick','cubeSelectionToolOff()');
    
    
    
    for(var i=0;i<allCubesAddedInterval.length;i++){allCubesAddedInterval[i].setAttribute('onclick','cubeSelectionToolOff()');
    
    beta++;
    allCubesAddedInterval[i].setAttribute('onmouseover','seven'+i+'()');                                                                                            
    if(beta==allCubesAddedInterval.length){beta==0}
    
    
    
    
    
    
    }
function bigImg {
  
}
function seven1(){}
function seven2(){}
        

    
    
}   
    
    
function cubeSelectionToolOff(){document.getElementById('cubeSelectionTool').style.boxShadow='none';document.getElementById('cubeSelectionTool').setAttribute('onclick','cubeSelectionToolOn()')}   
    
    
    
    

    
function checkMouseover(){
    
    document.getElementById('smallButtonBottomLeftInitialCube').style.backgroundColor="green";
}
    
function checkMouseout(){
    
    document.getElementById('smallButtonBottomLeftInitialCube').style.backgroundColor="black";  
    
    
    
}
    
    
    
function addText(){}    
function addPen(){} 
function addThree(){
    
    
    
    cubeCounter++;
    
    
    for(var i = 0;i<3;i++){
        
        
        
    
        
        
        
    addThreeCubes = document.createElement('div');document.getElementById('CubeAside').appendChild(addThreeCubes);addThreeCubes.setAttribute('class','addingAndSubtractingCubes');addThreeCubes.innerHTML='<form action="sendCubeFormAttributes.php"><input class="checkOutMyInputClass" name="cubeText'+i+'"></form>';
        
    document.getElementsByClassName('checkOutMyInputClass')[i].style.visibility='hidden';   
        
    if(i==0){addThreeCubes.style='box-sizing:border-box;border:3px solid green; position:absolute;top:'+14+'%;left:'+35+'%;height:50px;width:50px;background-color:black;color:green;'}
    if(i==1){addThreeCubes.style='box-sizing:border-box;border:3px solid green; position:absolute;top:'+28+'%;left:'+35+'%;height:50px;width:50px;background-color:black;color:green;'}
    if(i==2){addThreeCubes.style='box-sizing:border-box;border:3px solid green; position:absolute;top:'+42+'%;left:'+35+'%;height:50px;width:50px;background-color:black;color:green;';}
                           
                           
    
                          }
    
    
    intervalOne = setInterval(function(){allCubesAddedInterval= document.getElementsByClassName('addingAndSubtractingCubes');
                                         
                                         
    if(cubeCounter%2!==0){document.getElementById('smallButtonBottomLeftInitialCube').setAttribute('onclick','substractLastThreeCubesAdded()');}else{document.getElementById('smallButtonBottomLeftInitialCube').setAttribute('onclick','addThree()');}},1);
    
    
                    } 
    
    function substractLastThreeCubesAdded(){
        allCubesAdded02 = document.getElementsByClassName('addingAndSubtractingCubes');
        
        for(var i=0;i<3;i++){console.log(allCubesAdded02[0]);allCubesAdded02[0].remove();
                                              
                                              }
        cubeCounter++;
    
    
    }
    
    
    
</script>   
</body>
</html>

<!--
                <!doctype html>
                <html>
                <head>
                <meta charset="utf-8">
                <title>Bologna</title>
                <style>
                #one {
                    box-sizing: border-box;
                    border: 14px solid green;
                    height: 22%;
                    width: 22%;
                    background-color: yellow;
                    position: absolute;
                    top: 10%;
                    left: 10%;
                }
                #two {
                    box-sizing: border-box;
                    border: 3px solid green;
                    height: 22%;
                    width: 22%;
                    background-color: yellow;
                    position: absolute;
                    top: 20%;
                    left: 10%;
                }
                #three {
                    box-sizing: border-box;
                    border: 3px solid green;
                    height: 22%;
                    width: 22%;
                    background-color: yellow;
                    position: absolute;
                    top: 30%;
                    left: 10%;
                }
                #four {
                    box-sizing: border-box;
                    border: 3px solid green;
                    height: 22%;
                    width: 22%;
                    background-color: yellow;
                    position: absolute;
                    top: 40%;
                    left: 10%;
                }
                </style>
                </head>

                <body>
                <div id="one" onclick="functionOne()">Cube Selection Tool</div>
                <div class="foo">Cube One </div>
                <div class="foo">Cube Two</div>
                <div class="foo">Cube Three</div>
                <script>

                    var a;

                    function functionOne(){
                    a = document.getElementsByClassName('foo');
                    for(var i=0;i<a.length;i++){a[i].setAttribute('onmouseover','godBless'+i+'()')}


                }   


                    function godBless0(){alert(789)}
                    function godBless1(){alert(790)}
                    function godBless2(){alert(791)}
                </script>
                </body>
                </html>

-->

I have commented out a minimal example and would like to know why the functions are undefined as their mouseover event is definitely set to the cube elements as one of their attributes. I set mouseover events with a basic for loop I would like any help that could be beneficial to me and the stackoverflow community as to why these functions are undefined.

How to simulate user inputs into a text field in javascript?

I recently stumbled into a fun little ARG with my little brother. In it, they have small areas that are restricted to “Employees” and require passwords to enter. When you enter the incorrect password for the button, it simply displayed red text saying that the password is incorrect, without refreshing the page or anything like that, so I thought it would be a fun little project to try to brute force the password. The passwords only contain capital letters and numbers and are 6 characters long. so far my program is able to successfully generate the brute-force passwords, but I struggle to figure out how to correctly input them into the text field and simulate the click on the button. The link I’ve included below is a screenshot of the inspect elements page, the two things I’m interested in are the input box, and the submit button on the bottom of the photo.

enter image description here

function replaceAt(string, index, replacement) {
    if (index >= string.length) {
        return string.valueOf();
    }
 
    return string.substring(0, index) + replacement + string.substring(index + 1);
}

const arr =["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9"];
let length = arr.length;
let str = "AAAAAA"
for (let i = 0; i < 36; i++){
  str = replaceAt(str,0,arr[i])
  for (let j = 0; j < 36; j++){
    str = replaceAt(str,1,arr[j])
    for (let k = 0; k < 36; k++){
      str = replaceAt(str,2,arr[k])
      for (let l = 0; l < 36; l++){
        str = replaceAt(str,3,arr[l])
        for (let m = 0; m < 36; m++){
          str = replaceAt(str,4,arr[m])
          for (let n = 0; n < 36; n++){
            str = replaceAt(str,5,arr[n])
           // window.alert(str);
            document.getElementById("SM_ROOT_COMP_input").value = str
            setTimeout(()=>
            document.getElementsByClassName("_367Nj")[0].click()
            ,1)
          }
        }
      }
    } 
  }
}
window.alert("something went wrong")

Firestore: how to update a filed called likes. I wanna plus or minus one

I have a question about how to update a number field in Cloud Firestore. I followed an official document and it was not that hard to write code. But it didn’t work as I wanted.
It seems like I didn’t use async and await properly. I haven’t perfectly understood async and await now, so no idea where I missed.

GoodBad.jsx

import { useState } from 'react';
import { FaHeart, FaRegHeart } from 'react-icons/fa';
// import { FaThumbsUp, FaRegThumbsUp } from "react-icons/fa";
import {updateDoc, getDoc, doc } from 'firebase/firestore';

import db from '../config/firebase';

const GoodBad = ({ quiz }) => {
  const [goodClicked, setGoodClicked] = useState(false);
  const [goodCounter, setGoodCounter] = useState(quiz.likes);

  // console.log(quiz.id, quiz.likes)

  const handleLikesUI = async (e) => {
    if (goodClicked === false) {
      setGoodClicked(true);
      setGoodCounter(prevState => prevState + 1);
    } else {
      setGoodClicked(false);
      setGoodCounter(prevState => prevState - 1);
    }

    const docRef = doc(db, "quizzes", quiz.id)
    const payload = {likes: goodCounter}
    await updateDoc(docRef, payload);
  };


  return (
    <div className='quizFooter'>
      <div
        className={
          goodClicked
            ? 'likesCounterContainer checked'
            : 'likesCounterContainer'
        }
        onClick={() => handleLikesUI(quiz)}
      >
        <span className='heartIcon'>
          {goodClicked ? <FaHeart /> : <FaRegHeart />}{' '}
        </span>
        <span className='likesNumber'>{goodCounter}</span>
        {/* <span onClick={handleDislikes}>{goodClicked ? <FontAwesomeIcon icon="fa-regular fa-thumbs-down" /> : <FontAwesomeIcon icon="fa-solid fa-thumbs-down" />}bad: {badCounter}, {badClicked}</span> */}
      </div>
    </div>
  );
};

export default GoodBad;

React JS. losing control on API Calls. Multiple calls break my program

A brief summary of my program. My program is grabbing a facebook live comments and creating invoices if the trigger word is found in the comment.

Part of the problem: I’m unable to edit invoices due to the company not allowing edits on a existing invoice in their api. only deleting and creating a new invoice. my work around has been to grab an existing invoice. making the changes and saving this new version and deleting the previous.

The Problem: When multiple calls are made to the trigger function. All those calls are being made to the API at the same time. If any of those calls are to adjust the same invoice. The first call of the trigger function deletes the correct invoice and saves the updated one. When the 2nd call is calling the trigger function. It’s being done at the same time as the first. this means that the invoice it’s editing is not the updated one from the first call. This causes a problem because when it attempts to delete the previous invoice. It deletes the one the first call made. causing a “node is not found”.

attempts for solution. I have added await to the many functions and i’m not sure where to continue searching.

Facebook Live comment

// Links to a Facebook Live.
export const fblive = async (liveid) => {
  if (liveid != null) {
    try {
      const reg = new RegExp("\d{5,}");
      const found = liveid.match(reg);
      if (found > 0) {
        console.log(found, "  || ", found[0]);
        let activate = false;
     
        var userid = "";
        //var accesstoken = ''
        var accesstoken =''
        var videoID = found;

        var live_url =
          "https://streaming-graph.facebook.com/" +
          videoID +
          "/live_comments?access_token=" +
          accesstoken +
          "&comment_rate=one_hundred_per_second&fields=from{name,id},message";

        var source = new EventSource(live_url);

        source.onmessage = function (event) {
          var result = JSON.parse(event["data"]);

        

          let trigger_word = result["message"].search("#");

           // looking at comments
          readcomment(result["message"]);

          if (result["from"] != null) {
            console.log("FROM ! !:", result["from"]);
          }
          
        };
      } else {
        console.log("ZERO FOUND");
      }


    } catch (error) {
     
      console.log("FB LIVE COMMENT IS NOT RUNNING");
    }
  } else {
    console.log("Live ID not valid");
  }
};
// Looking at every comment in a facebook live
export const readcomment = async (the_comment) => {

  try {
    
 
  console.log(" CALLING LIVE READ COMMENT ", the_comment);
  let re = await new Promise((resolve) =>
  setTimeout(
    setTimeout(async function () {
      
      console.log(the_comment);
      
      if (the_comment.includes("#")) {
        populatelist();
        console.log(the_comment);

        let new_string = the_comment.trim().split(" ");
        console.log(new_string, " STRING SPLIT");
        
        let customer_found = await findcust(new_string);
        let item_found = await finditem(new_string);
        
        console.log(customer_found, item_found, "WE FOUND ");
        
        if (customer_found != false && item_found != false) {
          console.log("THERE'S A TRIGGER SALE HERE");
          
          let remove = await find_remov(new_string);
          console.log(remove, "WE ARE LOOKING AT RMOVE ");
          await comment_trigger(customer_found,item_found,remove)
        console.log(the_comment)

       console.log("promise for " , the_comment, " has been fullfilled")



    }
  }
}, 2000)
)
);
} catch (error) {
    console.log(error.response)
}
};
// This is when a comment was found to be the triggers words (customer id and a item name)
export const comment_trigger = async (customer, item, rmv) => {
  // FIND THE ITEM IN INVOICE.


 

  const client = find(customer, customer_list1);
  const real_item = find(item, item_list1);
  try {
    console.log(client, real_item);
    if (client != false && real_item != false) {
      let inv = await invoicesbycustomer(client.id);
      console.log(inv);

      if (inv == undefined || inv.length ==0) {
        console.log(customer, item);
        console.log(real_item.id);
        let new_Invoice = new Invoice("", client);
        let new_item = new Product(real_item.id, real_item.name, 1);
        await new_Invoice.addItem(new_item);
        console.log(new_Invoice);
        await createInvoice(new_Invoice);
        console.log("NO INVOICE WAS FOUND FOR THIS CLIENT");
      } else {
        console.log(inv);
       
        
          // making sure there's a real invoice.
          console.log("DATA TYPE IS ", typeof inv);
          if (typeof inv !== "undefined") {
         

            console.log(inv, "THIS IS INVOICE WITH CLIENT");
            console.log(inv[0].node.items.length);
            let oldItems = inv[0].node.items;
            let NewInvoice = new Invoice(
              inv[0].node.id,
              inv[0].node.customer.id
            );
            let Itemsize = oldItems.length;
            let found = false;
            if (Itemsize > 0) {
              //IF ITEMS EXIST ADD QTY.
              // ELSE ADD THIS NEW ITEM.
              for (let x in oldItems) {
              
                if (real_item.id == oldItems[x].product.id) {
                 
                  found = true;
                }
              }
            
              if (found && rmv == "removeqty") {
                await removeqtyitem(customer, item);
             
              } else if (found && rmv == "removeAll") {
                await removeitem(customer, item);
            
              } else if (found) {
                let aqi = await addqtyitem(customer, item);
               
              } else {
                // add item
                await additems(customer, item);
              
              }
            } else {
              await additems(customer, item);
             
            }
          }
        
      }
    } else {
      let errmssg = "";

      if (!client) {
        errmssg = errmssg.concat(" ", " Client is not valid ");
        console.log("client not found", errmssg);
      }
      if (!real_item) {
        errmssg = errmssg.concat("", " Item not found");
      }
      console.log(errmssg);
      console.error(errmssg);
    }
  } catch (error) {
 
    console.error(error.response.data)
  }



};

Here’s an example of the api being called. this is using graphql

//DELETING INVOICE API CALL
export const deleteInvoice = async(id) => {
  const invoiceId = id;
  console.log(invoiceId, "THIS I S INVOICE DELET EDELETE DELETE DELTE ")

  try {

  const token = "zCtQa00zlorbFFum6I7Rlzc0QwMDoS";
  const shema = ` 
  mutation ($input: InvoiceDeleteInput !) {
    invoiceDelete(input: $input) {

      didSucceed
      inputErrors {
        path
        code
        message
      }
    }
  }`;

  //About to submit my shema to waveapps
  const API_URL="https://gql.waveapps.com/graphql/public"
  const bussID = "QnVzaW5lc3M6ZTIyZmVhODEtNjg5OC00N2ZiLTgzOGItYWMyYzllNDZiM2Jk";
  let watch = await axios(API_URL, {
    method: "POST",
    headers: {
      Authorization: token ? `Bearer ${token}` : "",
      "Content-Type": "application/json",
    },
    data:{
      query: shema,
      variables: {
        input:{

          invoiceId: invoiceId,
        }
        
      },
    },
  })

    console.log(watch.data)
} catch (error) {
    console.log(error.response)
}
  //console.log("return delete invoice complete")
  
};

I have used async/await and promises.
When multiple calls are made. The await and promises are still being called at the same time. Not sure what else to look at? any suggestions please. I have spent a week on this.

Creating a nested Json from an array

I have this Js array:

tab[0]['city' => 'Paris', 'zip' => '75000']; 
tab[0]['city' => 'Toulouse', 'zip' => '31000']; 
tab[0]['city' => 'Marseille', 'zip' => '13000']

How to convert this array to Json?

{
  "city": "Paris",
  "zip": "75000"
},
{
  "city": "Toulouse",
  "zip": "31000"
},
{
  "city": "Marseille",
  "zip": "13000"
}

I tried with the JSON.stringify() function but I don’t get the expected result.

Thanks

Why expect({“[“”: 2}).toHaveProperty(“[“”) is not true in jest?

I would like to test that object has a property with the name ["

In node js I can definie object “x” with property "[""

> x = {"["": 2}
{ '["': 2 }
> x["[""]
2

and of course

> '["' ===  "[""
true

but when I typed test

expect({"["": 2}).toHaveProperty("["")

I received error:

Error: expect(received).toHaveProperty(path)

Expected path: "[""
Received path: []

Received value: {"["": 2}

These versions also not works

expect({"["": 2}).toHaveProperty(`["`);
const p = `["`;
expect({[p]: 2}).toHaveProperty(p);

Redirect User to specific URL depending of selected dropdown during submit

New to JavaScript seeking some help. (Trying to setup a form for my class students to fill)

I am working on Contact form 7 for WordPress. The form has several dropdowns. I want to redirect the students to a specific URL if the student select one of the dropdown options when submit. It is a bit complicated than that as per my example below.

Let me break it down a bit

So for example lets say i have three dropdown and on one of the three dropdown the options are “Mouse”, “Keyboard” and “Laptop” the other being “Wireless mouse”, “Wireless Keyboard” and “ChromeBook” and the last one being “Bluetooth Mouse, “Bluetooth Keyboard” and “Macbook”.

So if the first dropdown the student selects “Laptop” and on the second dropdowns they select “Wireless Mouse” and on the other they select “Bluetooth Keyboard” i want to redirect students to a “Laptop” URL as “Laptop” is the expensive/highest and overrides the other two.

If students have not selected “laptop” (or any of the laptops from any of the three dropdowns) and has selected “Keyoard” (or any of the keyboards) in at least one of the dropdowns (which is the next expensive item) i want to redirect to different URL

Below is an example of what i ended up with but noticed that document.getElementById() only supports one name at a time and only returns a single node and it wont work to identify the dropdown selects from the other two dropdowns

<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
  var lpLocation =  document.getElementById("item").value;
  if (lpLocation == "Mouse") {
    location = 'https://google.com';
  } else if (lpLocation == "Keyboard") {
    location = 'https://facebook.com';
  }
}, false );
</script>

I cannot wrap my head around how to proceed. I hope i am not going crazy. Any help from the experts will be much appreciated.

UnKnown unable to find smtp.gmail.com: No response from server

I tried setting up nodemailer

Initially I set it up with my gmail account. I have disabled two-factor authentication on it, and enabled IMAP. Here is the function that is supposed to send emails:

import { sendMailType } from '../../types/sendMail.d';
import nodemailer from 'nodemailer';

export const sendMail: sendMailType = async (to, link) => {

  const transporter = nodemailer.createTransport({
    host: 'smtp.gmail.email',
    port: 587,
    secure: false,
    auth: {
      user: process.env.USER, // [email protected]
      pass: process.env.PASS, // password
    },
  });

  let info = await transporter.sendMail({
    from: `Mikita <${process.env.SMTP_USER}>`,
    to,
    subject: 'Follow the link to confirm your email address',
    text: '',
    html: `
            <div>
                <h1>Follow the link to confirm your email address</h1>
                <a href="${link}" target="_blank">${link}</a>
            </div>
    `,
  });

  return { msg: info.messageId };
};

I was getting the following error:

Error: getaddrinfo ENOTFOUND smtp.gmail.email

I tried to run nslookup smtp.gmail.com
and got the error:
*** UnKnown unable to find smtp.gmail.com: No response from server

After that I tried setting up a test email so I converted the function to:

import { sendMailType } from '../../types/sendMail.d';
import nodemailer from 'nodemailer';

export const sendMail: sendMailType = async (to, link) => {
  let testAccount = await nodemailer.createTestAccount();

  const transporter = nodemailer.createTransport({
    host: 'smtp.ethereal.email',
    port: 587,
    secure: false,
    auth: {
      user: testAccount.user,
      pass: testAccount.pass,
    },
  });

  let info = await transporter.sendMail({
    from: `Mikita <${process.env.SMTP_USER}>`,
    to,
    subject: 'Follow the link to confirm your email address',
    text: '',
    html: `
            <div>
                <h1>Follow the link to confirm your email address</h1>
                <a href="${link}" target="_blank">${link}</a>
            </div>
    `,
  });

  return { msg: info.messageId };
};

I am assuming I have some kind of a DNS problem. How could I fix it?

ten un pequeรฑo error, para ver si me pueden ayudar [closed]

me gustaria recibir una acespria referente a este error
codigo:

    <style name="AppTheme.NoActionBar">
            <item name="windowActionBar">false</item>
            <item name="windowNoTitle">true</item>
     </style>
    
    el error que me sale asi y la verdad no se que hacer, soy nuevo en andorid studio


    AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{}],"original":"ERROR:AAPT: error: resource style/AppTheme (aka com.example.domiciliosblader:style/AppTheme) not found.nerror: failed linking references.nn    ","tool":"AAPT"}
    
    ERROR:AAPT: error: resource style/AppTheme (aka com.example.domiciliosblader:style/AppTheme) not found.
    error: failed linking references.

How to transform my local .json file into a node module?

In my program I have .json file that is stored in my local machine. Javascript code uses

require('../user/FILE.json') to get access to .json file and manipulate with it. Even tho it works on a local machine, people who cloned it from github are unable to run the program. The error says:

code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/me/progs/clonedRepo/technical-question/main.js' ]

I tried understanding on how to solve it, but i didn’t get it since I am new with it. All I understood is that there is a way to convert it into a node module and import that module after you cloned original repository.

Can anyone help me solving it? Explanations will be very helpful, since I didn’t got much from the Internet.

React useState hook – set value

I’m new to the whole React and React hooks staff, I’m trying to reset the value in useState to default if new filters are selected.

const [apartments, setApartments] = React.useState([])
const [page, setPage] = React.useState(1)
const fetchData = (onInit = true, loadMore = true) => {
        let setQuery = ''
        if (!loadMore) {
            setApartments([]) // <--- how to reset to empty?
            setPage(1) // <--- Not setting value to 1
        }
        if (!onInit || query()) {
            filtersWrapper.current.querySelectorAll('.select-wrapper select').forEach(item => {
                if (item.value) {
                    setQuery += `&${ item.name }=${ item.value }`
                }
            })
        }
        fetch(apiUrl + `?page=${ page }&pageSize=12${ setQuery }`)
            .then(res => res.json())
            .then(data => {
                setApartments([...apartments, ...data.apartments] || [])
                setHasNextPage(data.hasNextPage)
                setPage(prev => prev + 1)
            })
    }