0 Replies Latest reply on Dec 3, 2015 7:42 AM by Christianhchuk

    Checkbox value to toggle either spawning of template, or deletion of page.

    Christianhchuk Level 1

      Hi Everyone!

       

      I am definitely new to Javascript but have had success before using single commands. This is a little out of my skill level I think. I have a checkbox, that if 'checked', should spawn a template that the user needs to fill out as part of an application.  If the user makes a mistake and wants to uncheck the box, I want that page to be deleted.  It sounds simple as I say it, but it's been very difficult to code for.

       

      Broken down in more detail:

       

      I am trying to:

      • Spawn template "CHES"
        • Condition #1: Checkbox ("Type of CE - CHES Yes") is marked as 'checked' (Value = Yes) <- Is this correct?

       

      • Delete page containing hidden text "CHESDELETE"
        • Condition #1: Checkbox ("Type of CE - CHES Yes") is marked as 'checked' (Value = Off) <- Is this correct?
        • Condition #2: Page contains hidden keyword "CHESDELETE", and if that criteria is met, delete that page.

       

      Below is the code I have been trying to work with.  The "for" statements are very confusing for me, so those might be garbage.  I also get "Syntax Error: 9: at line 10", which is a blank line in the javascript window.  I have tried adding and deleting parentheses and squiggly bars to get that to go away... but I have a feeling this has deeper issues to be resolved.  Any and all help is GREATLY appreciated!!!

       

      var a = this.getTemplate("CHES");

      var check = this.getField("Type of CE - CHES Yes");

      for (var p = this.numPages-1; p>=0; p--)

          for (var n=0; n<this.getPageNumWords(p); n++);

       

      if (check.value == 'YES')

      {a.spawn};

       

      else if ((check.value == 'Off') && (this.getPageNthWord(p, n) == "CHESDELETE"))

      {this.deletePages(p); break;}