#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    4
    Rep Power
    0

    Question use of Javascript Confirm Box with Cold Fusion


    I am using the Javascript confirm box with ColdFusion to confirm any kind of delete...

    but the following code does not work.....

    <script language="JavaScript">

    VAR input_box = confirm ("Are you sure you want to delete this note?");

    if (input_box == false)
    {
    Javascript: window.history.go(-1);
    }

    if (input_box == true)
    {
    <CFSTOREDPROC datasource="#Application.PTS_DSN#" procedure="budget_track.del_note">

    <CFPROCPARAM cfsqltype="CF_SQL_INTEGER" dbvarname="v_note_seq" TYPE="IN" value="#note_id#">

    <CFPROCPARAM cfsqltype="CF_SQL_VARCHAR" dbvarname="v_usr" TYPE="IN" value="#session.UserLogin#">

    </CFSTOREDPROC>

    }
    <cfoutput>
    window.opener.location = 'PTSSummary1.cfm?budget_id=#budget_id#&FLAG_ID=#FLAG_ID#';
    </cfoutput>
    self.close();
    </script>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Netherlands
    Posts
    99
    Rep Power
    12
    Remember that CF processes server-side, and JS client-side.
    Hence:

    <script language="JavaScript">

    VAR input_box = confirm ("Are you sure you want to delete this note?");

    if (input_box == false)
    {
    Javascript: window.history.go(-1);
    }

    if (input_box == true)
    {
    <CFSTOREDPROC datasource="#Application.PTS_DSN#" procedure="budget_track.del_note">

    <CFPROCPARAM cfsqltype="CF_SQL_INTEGER" dbvarname="v_note_seq" TYPE="IN" value="#note_id#">

    <CFPROCPARAM cfsqltype="CF_SQL_VARCHAR" dbvarname="v_usr" TYPE="IN" value="#session.UserLogin#">

    </CFSTOREDPROC>

    }
    <cfoutput>
    window.opener.location = 'PTSSummary1.cfm?budget_id=#budget_id#&FLAG_ID=#FLAG_ID#';
    </cfoutput>
    self.close();
    </script>

    The bold text is already processed when it reaches the client, so in this case the page just closes and the opener-page jumps, because of the last piece and furthermore JS is case-sensitive.

    Suggestion: use a form with the confirm in the onSubmit-event.

IMN logo majestic logo threadwatch logo seochat tools logo