Javascript/show select object menu
Expert: Rick Johnson - 1/19/2005
QuestionHi Rick,
Unfortunately, space requirements require me to keep the select object of type "select-one" - a dropdown menu and not a select list.
I'm working on a project for a health care company, and the doctors see a simple text list of medications along with such things as dose, route, frequency, etc. This list is text-only for a non-cluttered visual requirement. However, they need to be able to click on the text and modify it - so, when they click on it, I convert the innerHTML of the table cell into a select-one object.
I have all that working, but doctors are very picky. They don't like that they have to click once to bring up the select object, and then click again to bring up the drop-down menu, and then click a third time to select the new option. So, if I could bring up the select object, and also at the same time "open up" the drop-down menu as if they clicked on it - it would be perfect. And as I said before, space requirements prohibit the use of a select list such as you have on the link you sent.
If I can't find a way to do that, I'll just create my own simulated select object with the functionality I need - but I was hoping you might have some idea.
thanks,
Randy
-------------------------
Followup To
Question -
Hi there Rick!
This is Randy, one of the other JavaScript experts here at allexperts. :)
I have been trying now for a week to do something that seems so simple - I want to make a drop-down menu (<select> object) show it's list of <options> - just as though the user clicked on it.
I have tried everything I can think of and searched MSDN and the web, and it would appear that there is no method provided to do what I want. But before giving in and creating a simulated select object, I thought I'd check with you.
Any ideas? :)
Thanks for your help!
Randy L. Taylor
Answer -
Randy Taylor,
If you include the size modifier in the select statement you can control how many of the options are displayed. To see this in action and how to modify a select-option list see the following URL:
http://www.vistaviews.net/myPage/javascripts/javas82.htm
I hope this helps,
Rick Johnson
AnswerRandy Taylor,
There are days when it is difficult to remember that “Clients make paydays possible”. I have written client application code since the late 60s. I know how important a good client/user interface is. That said I also know that sometimes the client asks for too much.
I am sure you could create your own object and the methods associated with that object. The problem comes with code maintenance. If and when you hand this code off to the person who will maintain it if it is too convoluted his task is going to be more difficult. I have been handed code to maintain and because of poor documentation ended up rewriting modules because how they worked was not readily apparent.
I know of no “out of the can JavaScript solution” to the question that you ask. Thinking about the problem it appears that what you want is an “active menu” type of thing. Last year I became aware of an outfit located in Bangor Maine called OpenCube Inc. Their site is at:
http://www.opencube.com/. This menu system used code magic to generate a very complex JavaScript menu. Once uploaded to the doctors site changes and additions to the menu(s) are made by simply uploading a single file.
The major drawback to this system was when they modified the base product and forgot to include an upgrade path. I continue to use the earlier version, which does not have all the features of the newer product. An example of how I am using this menu system can be found at:
http://www.vistaviews.net/mypage/javascripts/
I draw your attention to Forms > Radio Buttons > Using which shows how mouse movement can be used to select from sub-menus. The early version I am using has a limit to the number of sub-menus. This has been expanded with the latest version. I do not know if this helps or not. I hope so.
Rick Johnson