Multiple Select Dropdown “Size” HTML Attribute – Number of Visible Options
-
I would love to be able to select the “size” attribute of select elements in HTML somehow with this plugin, which would allow me to customize the number of visible options in the drop-down list (whether single- or multi-select).
More info and a working example here:
https://www.w3schools.com/TAGS/att_select_size.aspAn example for why you would need this, is if you want to specify the height of your multiple-select dropdown by the amount of options you want to show, instead of having to adjust the CSS in your theme to display the height in pixels (which requires knowledge of the CSS being used to style the select element and it’s options, a different class for each different number of options in each different select element (pre-added to the CSS), and of course calculating the right value to put in the CSS).
You would just have to add this bit in, which would perfectly take care of everything:
If a user selects “Allow multiple selections” in the form-tag generator options box popup for “drop-down menu” (when clicked from the toolbar), you would simply detect that, and a new set of radio buttons would appear, for “Number of visible options [textbox]” or “Display ALL select options” (which would calculate the number of options in the select element, and set the “size” attribute to that number).
The default is “1” if single-select, and “4” if multi-select.
Here is the code difference you would be outputting:
<select multiple="multiple" name="weekdays[]"> <option value="Sunday">Sunday</option> <option value="Monday">Monday</option> <option value="Tuesday">Tuesday</option> <option value="Wednesday">Wednesday</option> <option value="Thursday">Thursday</option> <option value="Friday">Friday</option> <option value="Saturday">Saturday</option> </select>
vs.
<select multiple="multiple" name="weekdays[]" size="7"> <option value="Sunday">Sunday</option> <option value="Monday">Monday</option> <option value="Tuesday">Tuesday</option> <option value="Wednesday">Wednesday</option> <option value="Thursday">Thursday</option> <option value="Friday">Friday</option> <option value="Saturday">Saturday</option> </select>
Thanks for looking!
- The topic ‘Multiple Select Dropdown “Size” HTML Attribute – Number of Visible Options’ is closed to new replies.