Reputation: 35
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
Upvotes: 1
Views: 402
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