Tell me how to set the arr array to value (select-> option-> value). And the user should only output text that contains an array () array. Simply put, array shows text between tags.
and the value of the array is arr
Tell me what you need to fix in the code so that it is:
<select > <option value="0"></option> <option value="1">Замечание</option> <option value="2">согласовано</option> <option value="3">не согласовано</option> </select> at the moment it turns out only this way:
<select > <option value=""></option> <option value="Замечание">Замечание</option> <option value="согласовано">согласовано</option> <option value="не согласовано">не согласовано</option> </select> Code
var array = [" ", "Замечание", "согласовано", "не согласовано"]; //var arr=["0", "1", "2", "3"]; как разместить данный массив в value option var select; select=document.createElement('select'); select.name=this.dataset.name; select.dataset.id=this.dataset.id; select.type='text'; var val=this.innerHTML; select.value=this.innerHTML; this.dataset.old=this.innerHTML; this.innerHTML=''; for (var i = 0; i < array.length; i++) { var option = document.createElement("option"); option.setAttribute("value", array[i]); option.text = array[i]; select.appendChild(option); } select=this.appendChild(select);
option.setAttribute("value", array[i]);onoption.setAttribute("value", i);? - teran