onoptionclick event (Menu)



The onoptionclick event activates when a menu option on the Menu widget is clicked.  Two variables will be pre-set by the menu widget so you can use them inside your JavaScript code for the event:

  • value - the choice value of the selected menu option

  • text - choice text of the selected menu option

Example:

You could set your widget property to call a JavaScript function, and pass the 'value' variable that was pre-set by Profound UI as a parameter.

Then, in a separate JavaScript file you could code this function that will have all of the code to handle the menu options:

function processMenuOption(value) { switch(value) { case "01": // code to process menu option 01 would go here break; case "02": // code to process menu option 02 would go here break; case "03": // code to process menu option 03 would go here break; } }

Note:

When using onoptionclick, you are handling the response manually with JavaScript entered in the onoptionclick event, rather through the “menu response” property. The automatic submit (response) and the JavaScript click event are mutually exclusive. You can either have an automatic submit/response, or the custom JavaScript event. If you wish to use the 'menu response' property please ensure the onoptionclick event is completely blank.