Feb 03, 2014 C Basic Menu Driven Program. Ask Question 0. I have a question that should be simple but I can't find the answer anywhere. I have a menu driven C program that works perfectly when the menu options are numbers but I can't figure out how to change the numbers to letters. Oct 17, 2016 Learn How To Implement Menu Driven Program in C Programming Language. The Menu Driven style is normally used with Switch Case.However, here we have given different ways to implement Menu Driven style which uses Switch Case and Functions.
![Menu-driven Menu-driven](/uploads/1/2/5/7/125799677/666961391.jpg)
The concept of a JavaScript-based menus is simple. When you hover a mouse pointer over a menu, it starts any submenu and lets you choose one of the choices on the submenu, if desired. Relocating the mouse to a different menu closes the initial submenu and opens anothér.
Hów to style the HTML for the menus
This illustration is structured on greatly formatted listings. There are usually many various other methods to produce selections, but this technique works quite well. Theoretically, you could effortlessly shop the menus on storage or in a database and use JavaScript to create the required list code for you. Nevertheless, for right now, concentrate on the truth that this menu system is certainly stationary and provides specific choices as demonstrated in the subsequent program code:
There are usually three main menu choices: Home, Events, and Get in touch with Us. The Home menu does not have submenus. The Events menu does have got a submenu containing of Event 1, Occasion 2, and Event 3. The Contact menu provides Telephone, Email, and E-mail as subménus.
Défine the menus styles
The lists that you produced gained't appear very much like a menu at the start. The secret is usually the formatting offered by the CSS that comes after:
This CSS code is shown in the purchase of detail. The#menuformatting is for the bestlt;uI id=”ménu”gt;tag. The primary menu products are format in switch by the#menus liand#menu li adesigns. When a user hovers the mousé over a main menu item, the#menus li a:hoverstyle adjustments the background colour to natural.
The submenu formatting is achieved by the#menus uland#menus ul astyles. Once again, when the consumer hovers the mousé over a subménu product, the#menus ul a:hoverdesign describes a color change for that menu item.
How to produce the JavaScript functions
The JavaScript functions have got to execute four jobs. The initial task is definitely to track the standing of the menus program and make certain that the menus remains stable. The following code performs that task:
ThéItemvariable contains the present menu item.Timerretains a value that determines whén a submenu wiIl close instantly. If you put on't supply this value, the menus behaves very erratically, and customers may discover it challenging to select items. Finally, the code must offer a indicates to instantly close menus items when a user ticks outside the menus system, which is usually what thedocument.onclick = CloseMenu
project does.
![Menu-driven program on javascript mac Menu-driven program on javascript mac](/uploads/1/2/5/7/125799677/523579921.png)
The second task can be to provide a means for opening the submenus, which are usually concealed at the beginning. Producing the submenu noticeable allows accessibility to the articles it offers. The following code shows a technique for opening the submenus:
See that the code first checks to make certain that the previous submenu can be actually shut. In any other case, the consumer could observe two open submenus, which would definitely be confusing. After the code makes the earlier submenu hidden, it makes the present submenu noticeable. In both situations, the illustration relies on thevisibilityproperty or home to carry out the task.
The 3rd task is usually to offer a method for closing a menu. This particular feature is definitely a little challenging because you wear't always want the menus to shut immediately. Usually, the consumer earned't have time to choose a submenu product before it closes. The following code displays how to execute this job with a period hold off in location:
When the program requests that a submenu close, the code creates a 500 millisecond hold off, after which thewindowinstantly callsPerformClose. When an item is present,PerformClosesets itspresencehouse to hidden to conceal the submenu from look at.There are usually three methods in which á submenu can close. A submenu can near when a consumer selects another major menu product, when the consumer goes the mouse cursór off of thé submenu, or whén the user ticks on a major or submenu item. When a consumer is hovering the mouse ovér a submenu item, the program code must maintain the submenu open. That's the 4th task the software must carry out:
Simply because long as the consumer hovers the mousé over the subménu, it will remain open because the timer is constantly reset. The instant the user moves the mouse óff the submenu ór clicks one of the submenu items, the timer réstarts, and the subménu closes.