NAMAN GUPTA
NAMAN GUPTA

Reputation: 101

add a javascript query dynamically change the button label in Oracle Apex

I have created a button named "Freeze". I want to create a dynamic action that changes the name from "Freeze" to " "UnFreeze" on click. I have set the static id for the button as "Freeze_StaticID" and then created a dynamic action for the click event. Under True condition, I want to add a javascript query for the same. Can anyone please tell me the query I need to add for the same? I tried adding the code below but it didn't work.

$("#Freeze_StaticID").attr ('value', 'UNFREEZE')

Upvotes: 0

Views: 5617

Answers (2)

Paulo Künzel
Paulo Künzel

Reputation: 849

Just use the JavaScript API for Apex

apex.item("Freeze_StaticID").setValue("UNFREEZE");

Upvotes: 0

Falco Preiseni
Falco Preiseni

Reputation: 476

It depends on the HTML implementation. When it's a <button> element, then it works like this: $('#Freeze_StaticID').text('UNFREEZE')

Btw: It's jQuery behind the scenes. You can toggle the browser's developer console (F12) and execute the appropriate getter and see what the result is for:

$('#Freeze_StaticID').text();
$('#Freeze_StaticID').attr ('value');

When undefined is returned, it's the wrong approach because it should return the current title of the button.

Details:

Upvotes: 1

Related Questions