APEX-AT-WORK no image

Send HTML data with the POST method from APEX

Von Tobias Arnhold 2.01.2010
If you want to send data from your APEX application to an external website (like PHP) through the POST method. You can use the following example:

Add a new page (in my example it's page number 2)


Add a new button on the page where you want to send data from: BTN_SEND_DATE
With the following options:
Target is a: URL
URL Target: javascript:void(window.open('f?p=&APP_ID.:2:&SESSION.:::::', 'popup', 'toolbar=no,width=1024,height=768, resizable=yes,top=40,scrollbars=yes'));

On page 2: Add your variables

1 P2_ID Hidden -- Needs to be set before page load
2 T_NAME Hidden
3 T_DESC Hidden
3 T_USER Hidden
....

Set variable P2_ID before you open page 2


On page 2: Page Process - Before Header

BEGIN
IF :P2_ID IS NULL THEN
:T_NAME:= 'Error - No data selected';
:T_DESC := 'Error - No data selected';
:T_USER := 'Error - No data selected';
ELSE
-- Select data
SELECT t.t_name,
t.t_description,
initcap(:P1_USERNAME)
INTO :T_NAME,
:T_DESC,
:T_USER
FROM test_table r
WHERE t.t_id = :P2_ID;
END IF;
END;

On page 2: Page - Footer Text

<script>
html_GetElement('T_NAME').name = 'T_NAME';
html_GetElement('T_NAME').value= document.getElementById('T_NAME').value;
html_GetElement('T_DESC').name = 'T_DESC';
html_GetElement('T_DESC').value= document.getElementById('T_DESC').value;
html_GetElement('T_USER').name = 'T_USER';
html_GetElement('T_USER').value= document.getElementById('T_USER').value;

html_GetElement('wwvFlowForm').action='http://website/external.php';
html_GetElement('wwvFlowForm').method='post';
html_GetElement('wwvFlowForm').submit();
</script>

Forum entries which helped me a lot:
Thread: item name isn't what i specified
Thread: HTTP POST from APEX
Thread: HTML form in Apex page

Example page:
Jeff Eberhard's application

Thanks Jeff for your example and your posts about this topic!

Post Tags:

1 One Comment " Send HTML data with the POST method from APEX "

Jeff E. 03 February, 2010 20:57

You're most welcome! It's great to know someone found it useful.

--Jeff