1

Hello I have such a list. I want to add a checkbox to the elements in this list. When I make more than one selection I want to sum in an array of values that are selected from. "With Javascript"

<body>
<select id="mySelect" size="10" multiple >
 <option>Audi A5 Sportback 40TDI </option>
 <option>Audi S8 Plus+ Sport  650PS / Matrix /360°/</option>
 <option>Ford Kuga ST-Line #Pano #Kamera #Alcantara #LED #SONY</option>
 <option>Kia SPORTAGE GT-LINE #LEDER #PANO #ASSYSTENZ-PAKET</option>
 <option>Seat Ibiza 95PS XCellence #Kamera #Alcantara #Acc </option>
</select>
</body>

the result I'm looking for

function functname() {
selected= [];
select= document.getElementById("mySelect").selectedOptions;
for (var i = 0; i < dene.length; i++) {
    selectindex= select[i].text;
    selected.push(selectindex);
}
console.log(olustur);

}
selectedlist = ["Audi A5 Sportback....","Audi S8 Plus+ Sport...."]

I found the answer to my question, I add it here so that it may be useful to others.

function functname() {
selectedItemText = [];
selectOpt = document.getElementById("mySelect").selectedOptions;
for (var i = 0; i < selectOpt.length; i++) {
    selectItem = selectOpt[i].text ;// or index
    selectedItemText.push(selectItem);
}
console.log(selectedItemText);

}
heybelix
  • 35
  • 1
  • 4

0 Answers0