Pls how can I do this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Pls how can I do this?

When a form is made and I want to console.log the name the input. It can be done with name.value. but how can I output what the user input In a drop-down list.

12th Sep 2022, 11:12 AM
Elijah Adebanwo
Elijah Adebanwo - avatar
4 Answers
+ 8
🔸HTML : <select id="drop-down"> <option value="1">One</option> <option value="2">Two</option> <option value="3">Three</option> </select> <button onclick="show_val()">Output Drop-down Value</button> 🔸 JavaScript : function show_val(){ console.log(document.getElementById("drop-down").value) }
12th Sep 2022, 11:38 AM
Sujal
Sujal - avatar
+ 3
This can be done for example in this way: https://code.sololearn.com/WsJl7PZTN57L/?ref=app
12th Sep 2022, 1:44 PM
JaScript
JaScript - avatar
+ 3
Thanks a lot😊
12th Sep 2022, 2:43 PM
Elijah Adebanwo
Elijah Adebanwo - avatar
+ 2
https://code.sololearn.com/Wm4yeI9h9XqM/?ref=app Elijah Adebanwo It'll Display value on the time it's selected.
12th Sep 2022, 11:44 AM
I am offline
I am offline - avatar