Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Loop through checkbox in Oracle APEX 4.2 (using JQuery Mobile)

1057474Nov 28 2013 — edited Nov 28 2013

Hello!

I want question text and a report containing the possible answers is shown on a page. An answer can be selected by clicking on the checkbox. After hitting the submit button, the selected checkboxes containing the Answer Text, an answer_id and the current session_id are to be inserted into a table within the database.

Within Oracle APEX 4.2, I am using a classic report to achieve this. Thich is actually a bad solution, because the checkboxes within the report are shown as simple HTML checkboxes, instead of neat JQueryMobile checkboxes). Anyway, this is my current solution:

Is use this code for creating the classic report:

SELECT APEX_ITEM.CHECKBOX(1,answer_id), answer_id, answer_text

FROM ANSWERS

WHERE question_ID = :P10_Question_ID;


The insert of the data is done via the on submit process "On Submit - After Computations and Validations"

This is the code for the on submit process:

DECLARE var_session_id NUMBER := :P0_SESSION_ID;

BEGIN

FOR i in 1..APEX_APPLICATION.G_F01.COUNT LOOP

INSERT INTO STUDENT_ANSWERS (answer_id, answer_text, session_id)

SELECT a.answer_id, a.answer_text, var_session_id

FROM ANSWERS a WHERE a.answer_id = APEX_APPLICATION.G_F01(i)

END LOOP;

COMMIT;

END;


But this solution does not work. Instead, nothing is inserted into the database.

I don't know why the process is not inserting into the database, maybe there is something wrong with this line here WHERE a.answer_id = APEX_APPLICATION.G_F01(i) ?

I even tried a simple update process for testing purposes, but this doesnt work either:

BEGIN

FOR i in 1..APEX_APPLICATION.G_F01.COUNT LOOP

UPDATE STUDENT_ANSWERS SET text = APEX_APPLICATION.G_F03(APEX_APPLICATION.G_F01(i))

WHERE am_id = APEX_APPLICATION.G_F02(APEX_APPLICATION.G_F01(i));

END LOOP;

COMMIT;

END;


Can anybody tell me how to loop through a checkbox within ORACLE APEX 4.2 and how to insert the values ANSWER_ID, ANSWER_TEXT and SESSION_ID into the table STUDENT_ANSWERS after hitting the submit button? If you would know how to do it without using a report but a simple checkbox, this would be even more helpful for me!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 26 2013
Added on Nov 28 2013
1 comment
1,185 views