Archive · 3 February 2008
Checkbox in APEX
Written 18 years ago. Oracle APEX has moved on a lot since; check the current Oracle APEX posts too.
You want to create a checkbox in Oracle Application Express and get it’s value in javascript?
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
If you’ve more checkboxes (because the lov is returning more values) you can use following function to see what’s checked:

Originally published on Blogspot.
Comments
No comments yet. Be the first.