Bakhodir Ibragimov
Bakhodir Ibragimov

Reputation: 35

How can I copy value from dropdown once I select it to text area as text?

How do I copy the value of the department from the dropdown to the text area once I select it? For example if I select IT department I want it to appear in comment text area like "IT Department:"...comment ... Sorry I'm newbie for coding and I want to learn how to do it enter image description here

Upvotes: 1

Views: 402

Answers (1)

Ahmad
Ahmad

Reputation: 1479

Yeah, you can do with this DOM

const eleId = document.getElementById("dropdown");
const textArea = document.getElementById("text");

eleId.addEventListener("change", function() {
  textArea.innerHTML = this.value;
})
<select id="dropdown">
<option value="IT depart">IT depart</option>
<option value="CS depart">CS Depart</option>
<option value="BBA depart">BBA Depart</option>
</select>

<textarea id="text">
</textarea>

Upvotes: 1

Related Questions