Ask coding questions

← Back to all posts
How can I make a input drop-down?
tyagir2392 (1)

So I want to make a drop-down menu, where users don't have to choose the the given options and can make their own, but I can't find a way to do this, does anyone have way to make this with javascript and HTML?

Comments
hotnewtop
Coder100 (16872)

use something like an radio, the industry standard:

<label><input type="radio" name="e"> Option a</label>
<label><input type="radio" name="e"> Option b</label>
<label><input type="radio" name="e"> Option c</label>
<label><input type="radio" name="e"> Other (please specify): <input value="SAY"></label>

and its so easy no js required.

Andy_4sberg (50)

Make a link or button that hides/shows a form with text inputs.
This worked for me:

<script>
    function something() {
        // Put code here
    }
    function visible() {
        var is_visible = document.getElementById("menu");
        if (is_visible.style.visibility==='visible') {
            is_visible.style.visibility='hidden';
        } else {
            is_visible.style.visibility='visible';
        }
    }
</script>
<button onclick="visible()">Drop down menu</button>
<form id="menu" style="visibility: hidden;">
    <input type="text" placeholder="Textbox one" onchange="something()" id="txtboxone">
    <br>
    <input type="text" placeholder="Textbox two" onchange="something()" id="txtboxtwo">    
</form>