We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7455
    • 2,204 Posts
    I it possible to use javascript istite a plugin?
    to give an alert? or confirm?

    I tryed this:

    
    
    print ("<Script language=\"JavaScript\">
    if (window.confirm('do you want to run the script?') ) {");
    
    	script to run if yes
    
    print("} 
    </Script>");
    return;
    


    but that did not work
      follow me on twitter: @dimmy01
      • 22303 MODX Staff
      • 10,725 Posts
      I believe you can use the built-in alert() function available from the SystemEvent class that represents each event for outputting js warnings...
      <?php
      //... stuff here
      $msg = 'Some string...';
      $modx->event->alert($msg);
      //... more stuff here
      ?>
      but it does not do confirm dialogs.

      Are you trying to do this in events within the manager or on the front-end?
        • 7455
        • 2,204 Posts
        in the manager I Made a plugin than sends out a mail when a document is saved. and it would be nice to have an option to choose if you wand this mail to be send out.

        now I used a tv, when checkbox is selected then the mail wil be send out if not then no mail and the checkbox wil be cleared after saving. this works ok but could easely be forgotten.

        Dimmy
          follow me on twitter: @dimmy01