title: How do I dynamically add one or more text boxes to a region in Oracle Apex 5.1?
body: <p>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:</p>
  
  <ul>
  <li>P11_TESTBOX: The text box that contains the amount of necessary new boxes</li>
  <li>TEST: The button that, when pressed, fires the necessary dynamic action(s)</li>
  <li>Procedure TEST_THIS:  PL/SQL procedure that, when triggered by the button, will run and create the necessary boxes</li>
  </ul>
  
  <p>The procedure, as written presently (just trying to test to see if I can get it to work before implementing fully):</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE TEST_THIS (
      HOW_MANY        IN NUMBER)
  IS
  BEGIN
      FOR I IN 1..HOW_MANY LOOP
          HTP.P('&lt;input class="dynamicBoxes" id="P11_BOX_' || I || '" type="text" value="" /&gt;');
          HTP.P('&lt;br/&gt;');
      END LOOP;
  END;
  </code></pre>
  
  <p>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 <code>HOW_MANY</code>, passing :P11_TESTBOX as the number.  I kept getting the error </p>
  
  <blockquote>
    <p>Ajax call returned server error ORA-06502: PL/SQL: numeric or value
    error for Execute PL/SQL Code</p>
  </blockquote>
  
  <p>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:</p>
  
  <pre><code>alert(document.getElementById('P11_TESTBOX').value);
  </code></pre>
  
  <p>Not surprisingly, the number entered into the box was returned.  Sadly, the error still appeared.</p>
  
  <p>In an effort to ensure I tried <em>everything</em>, I changed the syntax of the PL/SQL procedure:</p>
  
  <pre><code>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 =&gt; 'P11_NEWBOX_0' || I,
                  p_Value =&gt; ''
              )
          );
      END LOOP;
  END;
  </code></pre>
  
  <p>Result:  The alert still gives me the number; the error still follows.</p>
  
  <p>The idea to try both versions came from <a href="https://apextips.blogspot.com/2015/05/building-dynamic-forms.html" rel="nofollow noreferrer">this website</a>. </p>
  
  <p>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.</p>