Page 1 of 1

Display select box options through script

Posted: Sun Aug 01, 2021 1:26 pm
by Theju112
Dear Scott and Team,

I have a text box and a select box in my rich DSPF. My requirement is simple. Whenever, the user clicks on the text box, a user click on the select box should be simulated and the dropdown with the list of options must be displayed. i.e, the select box options dropdown must be displayed as if the user clicked on it.

Please let me know if this can be achieved through a onClick event of the text box widget?

Code: Select all


<select onMouseOut="this.size=1;" onMouseOver="this.size=this.length;">
        <option>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
        <option>5</option>
      </select>

I have tried the above (replacing the MouseOut/MouseOver events with onClick) but this seems to grey out the select box.

Re: Display select box options through script

Posted: Sun Aug 01, 2021 3:36 pm
by Scott Klement
This sounds a lot like our Combo Box widget. Can you use that?

If you wanted to write your own... we don't actually use a select box for the combo box, even though it looks like one.. instead, we place an image that looks like a down arrow at the edge of the text box, and when you click it, it opens a div element that's styled to look like the list of options.

The code you provided would work as well... but, this does not quite do what you asked...? (It doesn't really open the dropdown, it just displays more options from the dropdown on the screen. If you look in the "All Widgets" section of the widget toolbox, you might notice we have both a dropdown and a list box -- these are actually the same widget with different settings. one shows multiple lines on the display, the other shows one but allows you to drop it down... that's what your HTML/JS code does, too.)