Community Forums 

Main Content

Expand drop down list to show all options

    Feb 12 2017 22:53:37

    #1

    Julianv

    Join date : 2017-02-12      Posts : 1

    I'm building a form and I want to use a drop down list rather than radio buttons. But I wish to show all 3 options immediately (say birth, death, marriage) so that a customer can see them all and make make a selection without having to scroll down. Can this be done in Mal's?

    Also if a customer chooses the birth option, can then a label adjacent to a text field below the drop down list automatically show the word " birth"? Same for death and marriage?

    Hope I'm not asking too much. Thanks for your help



    Feb 13 2017 10:37:10

    #2

    Geoff

    Join date : 2008-09-18      Posts : 415

    To show all options in a dropdown use the size attribute. Javascript is used to display the selected option. Below is a simplified form to show how it would work.

    <form>

    <select size="3" onchange="document.getElementById('selection').innerHTML=this.options[this.selectedIndex].value">

    <option value="birth">birth</option>
    <option value="death">death</option>
    <option value="marriage">marriage</option>

    </select>

    <p><input type="text" value="">&nbsp;<span id="selection"></span></p>

    </form>