I am using Oracle Apex 5.1 to create a sample application. I am trying to create new text boxes based on a number entered into a field. So far, the actors in this play are:
The procedure, as written presently (just trying to test to see if I can get it to work before implementing fully):
CREATE OR REPLACE PROCEDURE TEST_THIS (
HOW_MANY IN NUMBER)
IS
BEGIN
FOR I IN 1..HOW_MANY LOOP
HTP.P('<input class="dynamicBoxes" id="P11_BOX_' || I || '" type="text" value="" />');
HTP.P('<br/>');
END LOOP;
END;
Like normally, I set a dynamic action on TEST: Event is set to 'Click', Selection Type is 'Button', Button is 'TEST', Event Scope is 'Static'. The True action is 'Execute PL/SQL Code', which is a simple call to the procedure HOW_MANY
, passing :P11_TESTBOX as the number. I kept getting the error
Ajax call returned server error ORA-06502: PL/SQL: numeric or value error for Execute PL/SQL Code
Thinking I was going crazy (which, let's be honest, isn't that far from the truth at this point), I added an 'Execute JavaScript Code' function:
alert(document.getElementById('P11_TESTBOX').value);
Not surprisingly, the number entered into the box was returned. Sadly, the error still appeared.
In an effort to ensure I tried everything, I changed the syntax of the PL/SQL procedure:
CREATE OR REPLACE PROCEDURE TEST_THIS (
HOW_MANY IN NUMBER)
IS
BEGIN
FOR I IN 1..HOW_MANY LOOP
HTP.P(
apex_item.text(
p_idx => 'P11_NEWBOX_0' || I,
p_Value => ''
)
);
END LOOP;
END;
Result: The alert still gives me the number; the error still follows.
The idea to try both versions came from this website.
Just to preempt myself, once I am able to sort this issue out, I will need to grab whatever values are entered into the created text boxes and insert them into the database. I'm hoping that's as simple as using whatever the IDs are that get created, but I'm not optimistic after this issue. Any help would be greatly appreciated.
You dont need to write a PL/SQL Procedure. Just hide the boxes on Page Load an when triggered the button the dynamic action shows them ? So you go to Server Side Action and Item = Value and also set this in the DA