I have a textarea
<textarea id="tarea" class="textarea" cols="15" rows="10" disabled></textarea>
and I want to send the values from my comboboxes to the textarea
<div class="form-group col-xl-7">
<label>Livro</label>
<div id="combo">
<select id="comboLivros">
<option class="option"></option>
</select>
</div>
<br>
<label>Proprietário a que se refere</label>
<input type="text" id='prop_desc' disabled/>
<br>
<label>Pontuação</label>
<select id="seleciona">
</select>
</div>
Those are my combobox that are filled with an array
I want when I select the comboboxes with the values i choose when I click on a button I want the textarea to be filled this is how I fill one of my combobox
var select = document.getElementById("seleciona");
var options = ["1", "2", "3", "4", "5"];
for (var i = 0; i < options.length; i++) {
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);
}
this is how I fill one of my combobox
You can use event change of select to set value of textarea:
var select = document.getElementById("seleciona"); var options = ["1", "2", "3", "4", "5"]; for (var i = 0; i < options.length; i++) { var opt = options[i]; var el = document.createElement("option"); el.textContent = opt; el.value = opt; select.appendChild(el); } var textarea = document.getElementById("tarea"); select.onchange = function(){ textarea.value = select.options[select.selectedIndex].value; }
<textarea id="tarea" class="textarea" cols="15" rows="10" disabled></textarea> <div class="form-group col-xl-7"> <label>Livro</label> <div id="combo"> <select id="comboLivros"> <option class="option"></option> </select> </div> <br> <label>Proprietário a que se refere</label> <input type="text" id='prop_desc' disabled/> <br> <label>Pontuação</label> <select id="seleciona"> </select> </div>
I hope it help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.