dante deo
dante deo

Reputation: 63

Set display value of text field on change of other text item in Oracle ApEx

I have an Oracle ApEx (version 4.2.5) database application with 1 "Home" type page displaying the current records in a table and a "DML Form" type page where you can insert/update/delete records to the same table. That is a generic "Report and Form" type application.

On the 2nd page, I want to set value of 4 text fields on change of a specific text field named P2_KOD. For that, I have created a dynamic action regarding that specific text field. I have set event to "Change", selection type to "Item(s)", item(s) to "P2_KOD" and left condition null (ie. "- No Condition -").

Then I have added a true action to set values of 4 text fields. I have tried "Set Value" actions of both "PL/SQL Function Body" and "JavaScript Expression". But I could not manage to set display values of that 4 text field. I know that I can set the session values of that 4 text field since I see them in "Inserted" state with correct item values assigned in the "Seesion" info.

What is wrong with my configuration?

Edit#1: I have created the same scneario on apex.oracle.com. You can login with the following credentials and check out the "Application 76791 - Simple Rep & Form App". There is a dynamic action named "WHEN_DEPT_CHANGED" which should change the value of P2_COMM to 3 times the value of department.

Workspace: DANTE_DEO
UN       : anonymous_developer
PW       : ad

Upvotes: 0

Views: 17974

Answers (2)

Pars
Pars

Reputation: 413

Please look at page 3 or Tab name "Pars test" in your application, some changes reflected in page.

As follows, add dynamic action

Event: Change   
Selection type :Items  
items:P3_DEPTNO   
Action: Execute javascript Code   
Code:   
var x = $v("P3_DEPTNO");   
var x = parseInt(x) * 3;  
$s('P3_COMM', x);

which changes your P3_COMM value to 3 times to value of P3_DEPTNO you have entered one.

Check Page 3, application 76791 for demo.

Upvotes: 1

Dave Lyndon
Dave Lyndon

Reputation: 796

You are getting the error:

Uncaught TypeError: string is not a function 

For this JS in 'Execute JS Code':

$x('P2_COMM').innerHTML = $x('P2_EMPNO').value() * 3;
$x('P2_COMM').value = $x('P2_EMPNO').value() * 3;

It's because .value() is not a function, it's like a property. Change to:

$x('P2_COMM').innerHTML = $x('P2_EMPNO').value * 3;
$x('P2_COMM').value = $x('P2_EMPNO').value * 3;

And you should be in business.

Handy hint: You can debug JS code in Apex (or anything) by using the console in Google Chrome (hit F12, navigate to console and refresh the page) or with the Firebug extension in Firefox.

Upvotes: 2

Related Questions