JavaScript. How get input values

JavaScript. How get input values
0

Hi all. I have a question…
How to get all inputs values and store it in the array?

getInputValue = () => {
  let inputsArray = [];
  let inputValue = document.querySelector(".input").value;

 inputsArray.push(inputValue);

  console.log(inputsArray);
};

I tried this code, but i get only the value of the first input.
I tried also querySelectorAll but than i get undefined…
Thanks!!

Hello @AmaliaTadevosyan,

  • I cannot really understand and help you, because the code is only cut of the whole code. Can you maybe give us the HTML part of this input?
getInputValue = () => {
  let inputsArray = [];
  document.querySelectorAll(".input").forEach(item => {
    inputsArray.push(item.value)
  });

  console.log(inputsArray);
};
1 Like

Super :+1:
This is exactly what I was looking for.
Thanks!!!

Hi. I have multiple inputs in HTML I need to get those values and sort it from lowest to highest.

1 Like

Yup, I see that you found your solution. That’s great, sorry I didn’t help you much. Anyways, Happy Coding !!:slightly_smiling_face:

1 Like