Skip to Content
author's profile photo
Former Member

Problem - JavaScript Confirm For PopUp Not Working

Dear All,

I was trying for one popup depending on some condition in View of BSP. The popup doesn't pop on the web page. With debugging I found that the debugger simply pass on from the confirm function. And on web page status bar a warning icon appears.

I am using MVC pattern for the development.Kindly let me know what I am missing here.

<script language="JavaScript" type="text/javascript">

function ConfirmChoice2()

{

var answer.

answer = confirm("Do You Want To Continue?");

<%= W_POPUPVAL %> = answer;

}

</script>

<%

IF W_POPUPVAL = 1.

W_POPUPRET = 'TRUE'.

ELSE.

W_POPUPRET = 'FALSE'.

ENDIF.

%>

Regards

Sapna Modi

Add comment
10|10000 characters needed characters exceeded

1 Answer

  • Posted on Feb 01, 2005 at 03:35 PM

    Hi Sapna,

    have a look at the following thread (the part written by Brian McKellar). There the basic parts of using Javascript variables in BSPs were explained.

    view-refresh

    Regards,

    Rainer

    Add comment
    10|10000 characters needed characters exceeded

    • Sapna,

      We are not going to get past the fact that to really do great things, you will unfortunately at the end of the day have to invest time to understand this technology.

      We have now invested time in your problem. One day you must return the investment!

      Some short comments:

      (1) There is no <form> sequence.

      (2) "IF flag = 'TRUE'" will fail because the value is actually 'true'. Very subtle. Change code to be "IF flag CS 'TRUE'". Look in ABAP online help to what does CS (Contain String) do.

      (3) After the confirm() JavaScript code, you need to actually return to server with the answer. This is done by submitting the form. (You now did add one?)

      Below is a complete example for you to play with. Cut and paste this example onto one BSP page. Save. Activate. Fetch coffee. Close door. Gime 10 points. Test. Test. Do not leave the computer for one hour.

      It is not complex. But it is also not easy. Hang around!

      brian

      <html>
       <body>
         <form name=myFrm>
       
          <%-- add here request counter, just to see interaction --%>
          <% DATA: counter TYPE STRING.
             counter = request->get_form_field( 'counter' ) + 1. %>
          <input type=hidden name=counter value="<%=counter%>">
          <%=counter%>
       
          <%-- first question, are we in dirty state. We simulate. --%>
          <input type=submit name=action value="dirty">
          <input type=submit name=action value="clean">
          <% DATA: action TYPE string.
             action = request->get_form_field( 'action' ). %>
       
          <%-- if dirty, request a pop to confirm --%>
          <input type="hidden" name="save" value="">
          <% IF action = 'dirty'. %>
            <script language="JavaScript" type="text/javascript">
              document.all.save.value = confirm("Save?");
              document.all.myFrm.submit();
            </script>
          <% ENDIF. %>
       
          <%-- if we have confirmed state, we save --%>
          <% IF request->get_form_field( 'save' ) CS 'true'. %>
            <span style="color:green">Saved!</span>
          <% ENDIF. %>
       
         </form>
       </body>
      </html>