{"id":182,"date":"2017-09-12T11:51:23","date_gmt":"2017-09-12T09:51:23","guid":{"rendered":"http:\/\/geekinto.com\/?p=182"},"modified":"2017-09-12T12:51:19","modified_gmt":"2017-09-12T10:51:19","slug":"oracle-apex-how-to-show-an-alert-successerror-message-by-javascript","status":"publish","type":"post","link":"https:\/\/howoracleapex.com\/?p=182","title":{"rendered":"Oracle APEX | How to show an Alert Success\/Error Message by JavaScript?"},"content":{"rendered":"<p><strong>It&#8217;s simple just follow next\u00a0Steps &#8230;<\/strong><\/p>\n<p><em><strong>METHOD #1<\/strong><\/em><\/p>\n<ol>\n<li>Put next JavaScript code into Page Or Application level.\n<pre class=\"lang:js decode:true\">function showAlert(Type,Msg){\r\n    var findSpan = $('#APEX_SUCCESS_MESSAGE').length;\r\n    if (findSpan == 1){\r\n        $('#APEX_SUCCESS_MESSAGE').remove();\r\n\r\n        \/\/ Re-Run\r\n        showAlert(Type,Msg);\r\n    } else{\r\n            \/\/ Adding HTML code!\r\n            $('#t_Body_content').prepend(\r\n                '&lt;span id=\"APEX_SUCCESS_MESSAGE\" class=\"apex-page-success\"&gt;&lt;div class=\"t-Body-alert\"&gt;'\r\n                + '&lt;div class=\"t-Alert t-Alert--defaultIcons t-Alert--success t-Alert--horizontal t-Alert--page t-Alert--colorBG\" '\r\n                + 'id=\"t_Alert_Success\" role=\"alert\" style=\"display: none;\"&gt;&lt;div class=\"t-Alert-wrap\"&gt;&lt;div class=\"t-Alert-icon\"&gt;'\r\n                + '&lt;span style=\"color: white; font-size: 25px;\" class=\"fa fa-check fa-xl fa-anim-flash\"&gt;&lt;\/span&gt;&lt;\/div&gt;'\r\n                + '&lt;div class=\"t-Alert-content\"&gt;&lt;div class=\"t-Alert-header\"&gt;&lt;h2 class=\"t-Alert-title\"&gt;'\r\n                + Msg\r\n                + '&lt;\/h2&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;div class=\"t-Alert-buttons\"&gt;&lt;button class=\"t-Button t-Button--noUI t-Button--icon t-Button--closeAlert\" '\r\n                + 'type=\"button\" title=\"Close Notification\"&gt;&lt;span class=\"t-Icon icon-close\"&gt;&lt;\/span&gt;&lt;\/button&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;\/div&gt;&lt;\/span&gt;');\r\n\r\n                $('#t_Alert_Success &gt; div &gt; div.t-Alert-buttons &gt; button[title=\"Close Notification\"]')\r\n                    .on('click',function(){\r\n                    $('#APEX_SUCCESS_MESSAGE').remove();\r\n                });\r\n\r\n            if(Type=='s'){\r\n                $.when(\r\n                    \/\/ Auto close success message\r\n                    $('#t_Alert_Success').show(),\r\n                    $('#t_Alert_Success').fadeIn(300).delay(2000).fadeOut(400)\r\n                ).then(\r\n                        function(){\r\n                            $('#APEX_SUCCESS_MESSAGE').remove();\r\n                        });\r\n\r\n            }else if(Type=='e'){\r\n                    \/\/ Set error style ...\r\n                    $('#t_Alert_Success').attr('style','background-color: #e95b54;');\r\n                    $('#t_Alert_Success div div.t-Alert-icon span').removeClass('fa-check');\r\n                    $('#t_Alert_Success div div.t-Alert-icon span').addClass('fa-close');\r\n                    $('#t_Alert_Success').show();\r\n            }       \r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/li>\n<li>When you want to show alert message call showAlert JS function by&#8230;# In SUCCESS message case write &#8230;\n<pre class=\"lang:default decode:true \">showAlert('s','Done, Thank you!');<\/pre>\n<p># In ERROR message case write &#8230;<\/p>\n<pre class=\"lang:default decode:true \">showAlert('e','Error, Please check again!');<\/pre>\n<p>&nbsp;<\/p>\n<p>[embedyt] https:\/\/www.youtube.com\/watch?v=rT37SS5AhvU[\/embedyt]<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><em><strong>METHOD #2<\/strong><\/em><\/p>\n<p>by APEX JavaScript APIs<\/p>\n<p><strong><a href=\"https:\/\/docs.oracle.com\/database\/apex-5.1\/AEAPI\/apex-message-namespace.htm#GUID-0A5906E7-49E3-4703-B4A7-9FF3A056ECC8\">apex.message.hidePageSuccess<\/a><\/strong><\/p>\n<p><strong><a href=\"https:\/\/docs.oracle.com\/database\/apex-5.1\/AEAPI\/apex-message-namespace.htm#GUID-0A5906E7-49E3-4703-B4A7-9FF3A056ECC8\">apex.message.hidePageSuccess<\/a><\/strong><\/p>\n<p><strong><a href=\"https:\/\/docs.oracle.com\/database\/apex-5.1\/AEAPI\/apex-message-namespace.htm#GUID-230C2CC1-B721-4037-8384-7B5369F35A2F\">apex.message.showErrors<\/a><\/strong><\/p>\n<p><strong>Ref:\u00a0<\/strong><a href=\"https:\/\/docs.oracle.com\/database\/apex-5.1\/AEAPI\/apex-message-namespace.htm#AEAPI-GUID-D15040D1-6B1A-4267-8DF7-B645ED1FDA46\">https:\/\/docs.oracle.com\/database\/apex-5.1\/AEAPI\/apex-message-namespace.htm#AEAPI-GUID-D15040D1-6B1A-4267-8DF7-B645ED1FDA46<\/a><\/p>\n<p>Regards,<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s simple just follow next\u00a0Steps &#8230; METHOD #1 Put next JavaScript code into Page Or Application level. function showAlert(Type,Msg){ var findSpan = $(&#8216;#APEX_SUCCESS_MESSAGE&#8217;).length; if (findSpan == 1){ $(&#8216;#APEX_SUCCESS_MESSAGE&#8217;).remove(); \/\/ Re-Run showAlert(Type,Msg); } else{ \/\/&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,15,13,12,2],"tags":[],"class_list":["post-182","post","type-post","status-publish","format-standard","hentry","category-apex","category-css","category-jquary","category-jscript","category-oracle"],"_links":{"self":[{"href":"https:\/\/howoracleapex.com\/index.php?rest_route=\/wp\/v2\/posts\/182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/howoracleapex.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/howoracleapex.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/howoracleapex.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/howoracleapex.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=182"}],"version-history":[{"count":7,"href":"https:\/\/howoracleapex.com\/index.php?rest_route=\/wp\/v2\/posts\/182\/revisions"}],"predecessor-version":[{"id":189,"href":"https:\/\/howoracleapex.com\/index.php?rest_route=\/wp\/v2\/posts\/182\/revisions\/189"}],"wp:attachment":[{"href":"https:\/\/howoracleapex.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/howoracleapex.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/howoracleapex.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}