An example of a checkbox:
In my application I want to do an interactive search whenever the checkbox is checked.
So, how do you know if the checkbox is checked? Let's try with an example.
- Create a new "Check Box" item and give it a name, for ex. P26_CHECKBOX.
- In the List Of Values, put STATIC2: ;Y (this checkbox doesn't have a label, but will return the Y value whenever the checkbox is checked)
- If you look at the Session State (in the developer toolbar) of the item after a submit of the page, you see the checkbox item has a value of Y when it's checked...
- If you want to get the value of an item in javascript within APEX, you normally do $x('ITEM_NAME').value
- So let's try $x('P26_CHECKBOX').value -> it returns: undefined
- If you know a bit of javascript/html, you maybe think you need to use $x('P26_CHECKBOX').checked -> it returns: undefined
- The above doesn't work, because APEX is putting a number after the item. In my example: $x('P26_CHECKBOX_0')
- If you try with $x('P26_CHECKBOX_0').value, it return Y or with $x('P26_CHECKBOX_0').checked, it returns true... and that's what we'd like to have
- See it in action here
Dimitri,
ReplyDeleteIs it possible to use this code in a report that uses apex_item.checkbox in SQL query and then pass the apex_application.g_f10 as the checkbox value?
Hi Paul,
ReplyDeleteI missed your comment. I guess it will work yes, it's just javascript. If you have a unique name it should work. Try it and tell me ;-)
Dimitri