0

Im having a select tag with multiple selection. It has about 8 options. I want to make a text area or a place where it will show the options i have selected. Im working on something that will have like 100 options in select tag and i want to keep track of which options i select. Any ideas how to? It can be in javascript or jquery.

const ddselect = () => {
  var d = document.getElementById("node-input-options");
  let displayText = d.options[d.selectedIndex].text;
  document.getElementById("txtArea").value = displayText[i];
  console.log(displayText);       
};

This populates the textarea but with only 1 option.

Moamen
  • 440
  • 3
  • 10
ivexy
  • 21
  • 3
  • You need a data structure in between the –  Apr 08 '21 at 07:06
  • How would i implement that in code? – ivexy Apr 08 '21 at 07:13
  • Do you know how to create an object you can then update and read back later? –  Apr 08 '21 at 07:22
  • I made an array. In it i push the selected options. But i have no idea how to populate the textarea with multiple values – ivexy Apr 08 '21 at 07:27
  • Here's a basic example: https://jsfiddle.net/fktq87vn/ –  Apr 08 '21 at 07:28
  • Take a look in my example. I want to have multiple options outputed 1 under another lets say. Cucpake and gingerbread for example : https://jsfiddle.net/fktq87vn/ – ivexy Apr 08 '21 at 07:36
  • You need to fork the fiddle; you posted mine. –  Apr 08 '21 at 08:24
  • oops, sorry. https://jsfiddle.net/qaksw7bp/ here it is – ivexy Apr 08 '21 at 08:27
  • Ok, sounds like you primarily need this: https://stackoverflow.com/a/5867262/5734311 –  Apr 08 '21 at 08:43
  • Thank you, but i managed to fix it. – ivexy Apr 08 '21 at 09:38

0 Answers0