JavaScript Alert functionality in PL/SQL

I'm in need of implementing the JavaScript "Alert" functionality (display message and wait for user to acknowledge) in the "before displaying the page" PL/SQL block of portal reports and forms. While I'm at it - How about the JavaScript "history.back" function as well?
Is this possible? Can you point me in the right direction.

Hi,
Where Portal says "before displaying the page" what it means is that it will run this code before it starts to htp.p() out the HTML of the page.
In WebDB this was actually what happened, in Portal there are some elements of HTML output BEFORE this block of code is run.
Anyway I don't think that you can have an alert that displays before the page is loaded. The page will still show behind the alert.
To get around this you would need a blank page to show your alert that forwards you on to the required page.
The history function can be called by the onclick event of a button or you can access Javascript through an anchor tag:-
link text
Regards Michael

Similar Messages

  • Javascript Alert function

    Hi,
    i have inserted an .js file in my project and imported it, the file is correct and the function is called too, but it alway retur an error, and i dont know why
    i have put this imn my onclick event JSF html button:
    onclick='javascript:newConfirm( "Remove records","Delete selected records?", 1,1,0)'
    in my .js file i have this function
    js file
    function newConfirm(title,mess,icon,defbut,mods) {
    IE4 = document.all;
    if (IE4) {
    icon = (icon==0) ? 0 : 2;
    defbut = (defbut==0) ? 0 : 1;
    retVal = makeMsgBox(title,mess,icon,4,defbut,mods);
    retVal = (retVal==6);
    else {
    retVal = confirm(mess);
    return retVal;
    do i´m doing something wrong ?? i´m using IE and it doesnt work, if i use Mozila it works fine...
    cheers,
    Epsy

    Hi,
    does it go into the
    if(IE4) loop at all ?
    Frank

  • Javascript alert wiping page clean - HELP

    Hi - I am using the javascript alert function in order to tell a user that information entered on a form is incorrect - however, the alert makes the page go away when all I want is to return to that page so the user can correct just that piece of information and resubmit it
    Anyone have any ideas on this? I'm scratching my head over this!!
    Thanks!
    Beth

    Hi Savitha,
    Yes, you are right, there is difference between alert and confirm. I will pose a small example, I have a page where the user / client must(!!!) enter his name, otherwise I don't allow him to go further (to my next page). Here in Javascript I will check for the name field,
    if(confirm(document.myform.field_name.value)) {
    //submit the form
    }. Here user didn't enter anything and clicks on 'OK' in confirm dialog, then I am forced to take him to the next page. So, I don't want to provide that chance to the user and decide it programatically, but prompt the user to enter the name with an alert dialog.
    Hope I am clear.
    PS:-
    I have shown a sample statement in the form of document.myform.field_name.length==0;
    'You can do all your validations there', is what my point here.

  • Calling Javascript function from PL/SQL Process

    I am new to APEX and Javascript so please forgive my question.
    I have a process on page which successfully runs a few procedures etc. but now, as part of this process, I want to call a javascript function I have typed into the HTML Header.
    My question is how can I call the javascript function from my process? Is it possible?
    Many thanks
    Winnie
    ps. as an example my javascript looks like:
    <script language="JavaScript">
    function test(){
    var decision = confirm("Click a button below and watch what pops up next.");
    alert(decision);
    </script>

    See: How to call a javascript function from pl/sql?

  • Invoke Javascript alert withing a PLSQL Function Block

    Hello,
    I am having trouble trying to achieve the following functionality. I have a page with an update button. On submit of this update button I have created a PL/SQL Function Body which returns TRUE for CASE 1, and FALSE for CASE 2. If CASE1 is achived then the process will update the data in the underlying table and will do nothing for CASE2. What I simply want to do is for CASE2, I also want to throw up an Alert informing the user that he is in CASE2. My existing PL/SQL function looks something like:
    BEGIN
    IF CASE 1 THEN
    RETURN TRUE;
    ELSE
    RETURN FALSE;
    END;
    I want something like:
    IF CASE 1 THEN
    RETURN TRUE;
    ELSE
    RETURN FALSE;
    javascript:alert('Update did not work!');
    END;
    Can anybody help me?
    Thanks
    Mitesh

    If you have submitted the page it is too late for javascript to run, javascript runs in the client, and the pl/sql runs on the server. If you want that to popup at that point you will need to have it popup on onLoad of the resulting page. Or do all of the validation in javascript then have javascript submit the page.

  • Not able to display javascript alert message from within a pl/sql block

    Hello,
    Can anyone please help me out with this issue. I wanted to display an javascript alert message from within a pl/sql block for an update button. Below is sample code which i am using. P1_ITEM is my hidden item on the report.
    begin
    if :P1_ITEM IS NOT NULL then
    HTP.p ('<script type="text/javascript">');
    HTP.p ('alert(''Please complete the item which is already assigned to you!'');');
    HTP.p ('</script>');
    end if;
    end;
    and I have made this code to be executed conditionally when request = Expression1
    Expression1: SUBMIT
    The thing is I am not able to display an alert message when the update button is clicked.
    Can anyone please help me with this one.
    Thanks,
    Orton

    varad but I also have an update statement within that block for the update button something like this i want to achieve.
    begin
    if :P1_ITEM IS NULL THEN
    update sample_tbl
    set col1 =:APP_USER,
    col2 = 'Y'
    where pk_col = ---;
    commit;
    HTP.p ('<script type="text/javascript">');
    HTP.p ('alert(''Successfully assigned an item!'');');
    HTP.p ('</script>');
    end if;
    if :P1_ITEM IS NOT NULL then
    HTP.p ('<script type="text/javascript">');
    HTP.p ('alert(''Please complete the item which is already assigned to you!'');');
    HTP.p ('</script>');
    end if;
    end;
    thanks,
    Orton

  • How to call javascript function from PL/SQL procedure

    Can anybody advice me how to call javascript function from PL/SQL procedure in APEX?

    Hi,
    I have a requirement to call Javascript function inside a After Submit Process.
    clear requirement below:
    1. User selects set of check boxes [ say user want to save 10 files and ticks 10 checkboxes]
    2. user clicks on "save files" button
    3. Inside a After submit process, in a loop, i want to call a javascript function for each of the file user want to save with the filename as a parameter.
    Hope this clarify U.
    Krishna.

  • Javascript embedded in button pl/sql event handler not being executed

    Javascript calls not working from pl/sql button event handler. What am I missing? Are specific settings needed to execute javascript from pl/sql proceedures?
    Example: Want to toggle target='_blank' off and on in a button pl/sql event handler to open url call in new window & then reset when processing submit is done & the app returns to the form.
    portal form button's pl/sql submit handler:
    begin
    htp.p('<script language=JavaScript>') ;
    htp.p('this.form.target="_blank"') ;
    htp.p('</script>') ;
    PORTAL.wwa_app_module.set_target('http://www.oracle.com') ;
    htp.p('<script language=JavaScript>') ;
    htp.p('this.form.target="_blank"') ;
    htp.p('</script>') ;
    end ;
    Putting the following in the button's javascript on_click event handler works great:
    this.form.target='_blank'
    to force opening new window with a call in the button's submit pl/sql code via:
    PORTAL.wwa_app_module.set_target('http://www.oracle.com') ;
    but then the target='_blank' is left on when the submit is done & we return to the form.
    putting the above javascript as a function (called fcn_newpage) elsewhere (e.g., after form opens) & calling in the submit pl/sql with
    htp.p('fcn_newpage') ;
    also doesn't work.
    Metalink thought this was an application issue instead of a bug, so thought I'd see if anyone knows what's going wrong here. (Portal 9.0.4.1)

    thanks for your discussion of my post.
    Please clarify:
    "htp.p('fcn_newwindow') sends a string":
    What would you suggest the proper syntax for a function fcn_newwindow() call from a pl/sql javascript block that differs from
    htp.p('<script language="Javascript">') ;
    htp.p('fcn_newwindow');
    htp.p('</script>');
    or more simply
    htp.p('fcn_newwindow') ;
    More generally, what I'm trying to figure out is under what conditions javascript is executed, if ever, in the pl/sql of a button (either the submit or custom event handler, depending on the button).
    I've seen lots of posts asking how to do a simple htp.p('alert("THIS IS TROUBLE")') ; in a pl/sql event handler for a button on a form, but no description of how this can be done successfully.
    In addition to alerts, in my case, I'd like to call a javascript fcn from a pl/sql event handle that would pass a URL (e.g., http://www.oracle.com) where the javascript fcn executed
    window.open(URL). The API call to set_target(URL) in pl/sql has no ability to open in a new window, so calling that is inadequate to my needs and I must resort to javascript.
    Its clear in the PL/SQL of a button, you can effect form components since p_session..set_target & p_session.get_target set or get the contents of form components.
    So to see if javascript ever works, I tried to focus on something simple that only had to set what amounts to an enviromental variable when we returned to the form after a post. I chose to try to change the html value of TARGET from javascript in the PL/SQL button because it doesn't need to be implemented until we finish the post and return to the form.
    So I focused on a hack, setting this.form.TARGET='_blank' in the on_click event handler that forced every subsequent URL call or refresh of the form to be a new window. I then wanted to turn off opening new windows once I'd opened the URL call in a new window by setting TARGET='' in the portal form. I can achieve what I want by coding this.form.TARGET='' in the javascript (on_focus, on_change, or on_mousedown, ...) of every form component that might refresh the form. However, that is a ridiculous hack when a simple htp.p('<script>') ; htp.p('this.form.target=""') ; htp.p('</script>') ; at the end of the button's pl/sql event handle should do the same thing reliably if javascript ever works in the pl/sql event handler.
    If we didn't have access to form components through p_session calls, I'd assume it was a scope issue (what is available from the pl/sql event handler). But unless my syntax is just off, when, if ever, can javascript be used in a portal form's pl/sql event handler for a button?
    if I code a javascript funtion in the forms' pl/sql before displaying form:
    htp.p('<script language="JavaScript">') ;
    htp.p('function fcn_new_window(URL)') ;
    htp.p('window.open(URL)' ) ;
    htp.p('</script>') ;
    the function can be called from a button's on_click javascript event handler:
    fcn_new_window('http://www.oracle.com')
    but from the same button's pl/sql submit event handler this call doesn't work: htp.p('fcn_new_window("http://www.oracle.com")')
    So my questions remain: Is there other syntax I need, or does javascript ever work properly from the pl/sql of a form button's event handler? If it doesn't work, isn't this a bug that should be fixed by Oracle?
    I can probably figure out hacks to make things work the way I need, but executing javascript from pl/sql event handlers seems to be the expected way to affect portal html pages (forms, reports, ...) and it seems not to work as expected. I don't feel I should have to implement hacks for something as simple as calling a javascript function from pl/sql when almost every example I've found in metalink or the forums or Oracle Press's "portal bible" suggests using javascript from pl/sql via the utility htp.p() to effect web page components in portal.
    My TAR on the subject, while still open, returned the result basically: "We can reproduce your situation. Everything looks okay to us, but we can't explain how to use javascript where you want or point you to any documentation that would solve your problem or expain why it should not work the way you want it to. We don't feel its a technical issue. Why don't you post the problem on the portal applications forum."
    I'm hoping I'm just missing something fundamental and everything will work if I implement it a little differently. So if anyone sees my error, please let me know.
    by the way, not sure this is germain, but in reference to your comment:
    "redirections in pl/sql procedures give a peculiar result. in a pl/sql procedure, usually, portals give the last redirection statement and ignore anything else coming after it."
    if I try to raise an alert:
    htp.p('alert("you screwed up")');
    return;
    in a pl/sql event handler, it still doesn't raise the alert, even though its the last thing implemented in the event handler. But if I set the value of a text box using p_session..set_value_as_string() at the same spot, it correctly sets the text box value when I return to the form.

  • JavaScript alert in AS3 or AS2 to debug the external actionscript file

    Hi,
    Is there any way to debug the external AS file as i dont want to use "trace".
    I have an idea to use the input text field the check the variable/function is working right but this is not enough so is there any process in AS2 or AS3.
    Thanks in advance..

    my mistake ..i have used there dynamic textfiled.
    but i got a easy solution by using
    getURL ("javascript:alert('Testing');");
    but this is not the good solution
    is there any way to import the alert contolls in AS2
    like i have read somewhere
    import mx.controls.Alert;
    Please reply..

  • Trouble with using javascript $s function to populate a page item

    Hello Oracle APEX Community,
    I'm working on a drilldown dashboard page and have been encountering a problem when i try to populate a Text Page Item (hidden or not) using the javascript built in $s function.
    The function works great when the data is a number such as dept_id (even if the field type is varchar). However, trying to pass anything which is a text the process fails, except when a value is hard-coded as a parameter for the function. So for example, I have a chart with counts of constituents by state. I would like to populate (filter) a table based on when you click on a bar for a state without having to submit the page. I'm using dynamic actions and a built in javascript function in the SQL for the chart to accomplish this; but again, it works great when I use a varchar field like the FIPS code (i.e. the FIPS for Texas is '48'), but when I try to populate the page item using the state abbreviation 'TX' (again varchar) it fails.
    Here's an example of code that works:
    SELECT 'javascript:$s("P1_DEPTNO",'||d.deptno||')' LINK,
    d.dname LABEL,
    sum(e.SAL) sal
    FROM emp e, dept d
    where e.deptno = d.deptno
    group by 'javascript:$s("P1_DEPTNO",'||d.deptno||')', d.dname And here's an example of code that does not work:
    SELECT 'javascript:$s("P1_DEPTNO",'||d.loc||')' LINK,
    d.dname LABEL,
    sum(e.SAL) sal
    FROM emp e, dept d
    where e.deptno = d.deptno
    group by 'javascript:$s("P1_DEPTNO",'||d.loc||')', d.dname However, when I hard code a text value the script works:
    SELECT 'javascript:$s("P1_DEPTNO","BOSTON")' LINK,
    d.dname LABEL,
    sum(e.SAL) sal
    FROM emp e, dept d
    where e.deptno = d.deptno
    group by 'javascript:$s("P1_DEPTNO","BOSTON")', d.dname
    ORDER BY d.dname I'm encountering this problem on several versions of APEX: (4.0.2.00.07-local installation) and (4.1.0.00.28-apex.oracle.com)
    Does anybody know of this problem and how to solve it? I've looked for settings on the page item itself, and can't figure it out.
    I've re-written my sql to utilize the value fields of my tables instead but I have some objects on the page which are really going to depend on the character based data instead.
    Thanks,
    Wayne

    In your javascript you are generating, surround your value with double-quotes and it'll should then always work with both numbers and strings (your strings are probably being interpreted as variable names and they don't exist at runtime, hence erroring out).
    Example:
    SELECT 'javascript:$s("P1_DEPTNO","'||d.loc||'")' LINK,Edited by: gti_matt on Aug 16, 2011 9:50 AM

  • Javascript:alert(1);

    javascript:alert(1);

    The first thing you have to do is to remove the ColdFusion conditional logic.  ColdFusion runs on the server.  JS runs on the client.
    The next thing is to call the function from an event that happens on the web page.  form onsubmit seems like a good choice.

  • Javascript alert problem - select state

    I am trying to validate my form with javascript. I'm having
    trouble with my state field. If the user selects a state javascript
    alerts the following message: "SELECT ONE is not a valid choice.
    Please choose your state." I want the alert message to pop up if
    select one is selected as a state. How do I fix this problem?

    pqer wrote:
    > I am trying to validate my form with javascript. I'm
    having trouble with my
    > state field. If the user selects a state javascript
    alerts the following
    > message: "SELECT ONE is not a valid choice. Please
    choose your state." I want
    > the alert message to pop up if select one is selected as
    a state. How do I fix
    > this problem?
    >
    >
    >
    > <script language="javascript"
    type="text/javascript">
    >
    > // check to see if the form is blank
    > function validForm(contactUs) {
    >
    >
    > if(contactUs.state.value != "SELECT ONE") {
    > alert("SELECT ONE is not a valid choice. Please choose
    your state.")
    > contactUs.state.focus()
    > return false
    > }
    if(!contactUs.state.selectedIndex) {
    alert("SELECT ONE is not a valid choice. Please choose your
    state.");
    contactUs.state.focus();
    return false;
    Mick
    >
    > </script>
    >

  • Javascript Alert

    How do I replicate the following AS2 function in AS3 completely in Flash WITHOUT writing any external javascript
    myBtn_btn.onRelease = function(){
    getURL("javascript:alert('you clicked me')");
    I know about the ExternalInterface option, but again I need to do this without creating/changing any external Javascript code.
    Thanks

    A slight tweak on kglads code to make it work with the security restrictions of the newest players.
    myBtn_btn.addEventListener(MouseEvent.CLICK,f);
    function f(e:MouseEvent):void {
         ExternalInterface.call("alert","you clicked me");
    This works without putting any JS code on the HTML page because the alert() function is native to JS.
    Also, if you want to do more elaborate things (custom functions, etc) - here is a tutorial on JS script injection with AS3:
    http://www.actionscript.org/resources/articles/745/1/JavaScript-and-VBScript-Injection-in- ActionScript-3/Page1.html

  • How to give a javascript alert befor doing any insert or update

    Hi,
    Is there any way to give a javascript alert befor doing any insert or update? I want to use default insert/update button.
    Thank you
    Sumita

    just add:
    alert('Updating Record...');
    in the onClick event field for the UPDATE_TOP/UPDATE_BOTTOM button.
    You can do the same for the INSERT_TOP/INSERT_BOTTOM button. Adding javascript code in the event fields will not supersede the default PL/SQL events assigned to those buttons, unless you specifically remove the PL/SQL code (e.g. doUpdate;)..

  • Javascript alert when showing all rows of a huge table ( 2000 rows)

    i've got this problem. I need to show all the rows of a table, i'm using ADF 10.1.3.4.
    What have i done so far?first of all i created a command link
    <af:commandLink shortDesc="Mostra Tutto" id="showAll"
    disabled="#{bindings.findAllVwEntePrmzRefrIter.estimatedRowCount == 0}"
    action="#{backing_editReferenza.onShowAll}"
    />
    In the backing bean i set the rangeSize of the table to -1
    public String onShowAll() {
    Object objShowAll = getSession().getAttribute("showAll");
    FacesContext fc = FacesContext.getCurrentInstance();
    ValueBinding vb = fc.getApplication().createValueBinding("#{bindings.findAllVwEntePrmzRefrIter}");
    DCIteratorBinding dc = (DCIteratorBinding)vb.getValue(fc);
    int oldRangeSize = dc.getRangeSize();
    dc.setRangeSize(-1);
    int rangeSize = dc.getAllRowsInRange().length;
    dc.setRangeSize(oldRangeSize);
    if ("Y".equals(objShowAll)) {
    getSession().removeAttribute("showAll");
    Integer oldRange =
    (Integer)getSession().getAttribute("oldRangeSize");
    getSession().removeAttribute("oldRangeSize");
    getTable1().setRows(oldRange);
    } else {
    getSession().setAttribute("showAll", "Y");
    getSession().setAttribute("oldRangeSize", oldRangeSize);
    getTable1().setRows(rangeSize);
    return "";
    // AdfFacesContext.getCurrentInstance().addPartialTarget(getTable1());
    Everything runs smoothly, but i have a problem if the table has lots of rows: i get a javascript warning that a script has been running for too long. (The alert goes: "Stop the execution of the script?" the usual javascript alert you get when a script runs for too long)
    What i want to achievt is that, if the table contains a lot of rows, the page takes a lot of time to load, but with no javascript involved (it's just a normal slow page).
    It seems that in some way the rows of the table are fetched by javascript and since the call is synchronous, it trigger the alert.
    This is how i declared the method iterator
    <methodIterator id="findAllVwEntePrmzRefrIter"
    Binds="findAllVwEntePrmzRefr.result"
    DataControl="FePrmzSLESSEJBLocal" RangeSize="10"
    BeanClass="it.ws.sma.prmz.ejb.model.VwEntePrmzRefr"
    Refresh="deferred"
    />
    and this is how i declared the table
    <af:table value="#{bindings.findAllVwEntePrmzRefr1.collectionModel}"
    var="row" styleClass="tableRefr #{backing_editReferenza.tableReferenzeStyleClass}"
    rows="#{bindings.findAllVwEntePrmzRefr1.rangeSize}"
    first="#{bindings.findAllVwEntePrmzRefr1.rangeStart}"
    emptyText="#{bindings.findAllVwEntePrmzRefr1.viewable ? 'Nessuna referenza trovata' : 'Accesso negato'}"
    binding="#{backing_editReferenza.table1}" id="table1"
    banding="row" bandingInterval="1"
    partialTriggers="btnEliminaRefr btnSvuotaPromo btnRemove btnAdd insVeloce">
    has anyone an idea onwhat could i do to have the table load all the rows from the server but withouth the alert?

    Sorry i haven't explain it well...
    the app is used to replicate entire databases, or agrupations of tables, from one database to another and it will have to be vendor independent... I'm trying with DB2, Oracle and MySQL. Later i will test it with more.
    Then I couldn't use vendor dependent SQL neither configuration parameters. Also I prefer to make the import logging the actions: for restoring purposes; maybe the user will have the option but defaults to the ohter.
    I'm thinking about some "strange" query SQL Stardard, like delete from table where (select .... using some kind of counter....

Maybe you are looking for