Pass Input Select List Captions
When a page containing an Input Select List (ISL) is submitted, the value from the designated Value Column in the selected row is passed to the next definition as a Request token, using the ISL's element ID. However, developers may also, or instead, want the Caption for the selected item. This is functionality that's not built into the ISL, so you must use some Javascript to make the text available. Here's how:
- Include an Input Hidden element in your definition (users will not see it), as shown above.
- Use an Event Handler to capture the onChange event beneath your Input Select List.
- Beneath the Event Handler add Action.Javascript.
- Enter the following Javascript code in the Source attribute (keeping in mind that it's case-sensitive):
/* get index of selected item in Input Select List (ISL) */ |
If you wish to submit the page right after the selection is made in the ISL, un-comment the next-to-last two lines and provide the definition name.
As you can see, the code stuffs the Caption (text) of the ISL's selected item into the Input Hidden and you can then read it in the next definition using @Request.myInputHiddenID~.
If using a Logi product version earlier than v10.0.259, you will not have the Action.Javascript element available, so you'll need to use Action.Link and Target.Link instead. In Target.Link's URL attribute, enter "javascript: " (without the quotes) and then code from above. In addition, the Javascript "this" object was not supported in those earlier versions, so you'll need to replace references to it in the code with:
document.getElementById('yourInputSelectListID')