Adi
Adi

Reputation: 309

ERR-1002 Unable to find item ID for item in multiple options select

I have a multiple option select and everytime i submit the page i get:

ERR-1002 Unable to find item ID for item "clients1" in application

for day in {something}

htp.p('<select class="custom-select" name="clients'||to_char(day+1)||'" id="clients'||to_char(day+1)||'" multiple>
<option selected>Open this select menu</option>');

for client in (SELECT id, name FROM    client) loop
   htp.p('<option value="'|| client.id ||'">'|| client.name ||'</option>');
end loop;

htp.p('</select></div></div></div>');

Looks like this :

<select class="custom-select" name="clients1" id="clients1" multiple=""><option selected="">Open this select menu</option>
<option value="1">Test</option>
...
</select>

I really can't find the problem. Tried to search for an answer but could not find anything.

Thanks in advance

Upvotes: 1

Views: 2792

Answers (1)

Tony Andrews
Tony Andrews

Reputation: 132570

APEX assumes that a form element such as a select list is an APEX page item if its name and id are the same, which yours are. So you can avoid this problem by making the names different from the IDs in some way.

The usual way to create bespoke form elements on an APEX page is to use the APEX_ITEM package, which has functions like SELECT_LIST_FROM_QUERY to generate form elements whose values can be accessed from PL/SQL after page submit via APEX_APPLICATION arrays.

Upvotes: 2

Related Questions