Show a Menu Dynamically
Last updated 21/08/2023
In Five, you do not need to show your menu all the time, you may have scenarios when you only want to show a menu sometimes or maybe not at all. You can choose when to have the menu item shown by providing a JavaScript statement in the Show If field.The Show If field contains a mask on the field to help you enter the correct code, your statement must be
true
, false
, or have an expression starting with an equals =
sign.By default, the Show If field is set to
true
, this makes your menu item shown. To not show a menu, simply edit the Show If field and type false
.Figure 1 - False show if
Add a JavaScript Statement
info
The example code will make it that the Specials menu will only be shown between 8:00am and 11:00am by using the
time()
function on the Five
object.1. Select your menu record in the list.
2. Either click the Edit button in the form app bar, or click directly in the Show If field.
Figure 2 - Edit the menu record
3. Type your JavaScript condition in the Show If field.
Only display the Specials menu between 8:00am and 11:00am
=five.time() > '08:00:00' && five.time() < '11:00:00'}
Figure 3 - Add your JavaScript condition
4. Click the Save button in the form app bar.
Figure 4 - Save the menu record