Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-63509

JavaScript inside "Formatted HTML" stop work, when Groovy script uses a value of another parameter

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: active-choices-plugin
    • Labels:
      None
    • Environment:
      Windows 10 64 bit
      java.version 1.8.0_162
      Tomcat 9.0.34
      Jenkins 2.254
      Active Choices 2.4
      Firefox 79.0
    • Similar Issues:

      Description

      Here is two parameters:

      Param1 - simple single select:

      return ['value1', 'value2']
      

      Param2 - formatted HTML:

      def tst = "new"
      html = '''
      <html>
      <body>
      <input type="checkbox" onClick="Result(this)" /> Select all<br/>
      <input type="checkbox" name="cbx" value="One" onClick="Result()"/> One<br/>
      <input type="checkbox" name="cbx" value="Two" onClick="Result()"/> Two<br/>
      <input type="checkbox" name="cbx" value="Three" onClick="Result()"/> Three<br/>
      <script>
      function Result(source) {
      	var checkboxes = document.getElementsByName("cbx");
      	var result = document.getElementById("result");
      	result.value = "";
      	for(var i=0, n=checkboxes.length;i<n;i++) {
      		if (source) checkboxes[i].checked = source.checked;
      		if (checkboxes[i].checked) result.value = result.value + checkboxes[i].value + ",";
      	}  
      	result.value = result.value + "''' + tst + '''";
      }
      </script>
      <input type="text" id = "result" name="value" value="''' + tst + '''">
      </body>
      </html>
      '''
      return html
      

      When Param2 does not use Param1 value, function Result works great:


      But when I try to use value of Param1, JavaScript does not work:

      def tst = Param1
      

       

        Attachments

          Activity

          Hide
          ngagex Vladimir Buravtsov added a comment - - edited

          From Console:

          Function Result is missing in build script:

           <tr><td class="setting-leftspace"> </td><td class="setting-name">Param2</td><td class="setting-main"><div name="parameter" id="choice-parameter-172075458256007" class=""><input name="name" type="hidden" value="Param2"><div id="formattedHtml_choice-parameter-172075458481046">[error]</div><input type="text" name="value" value="" style="visibility: hidden; position: absolute;"></div></td><td class="setting-no-help"></td></tr><tr class="validation-error-area"><td colspan="2"></td><td></td><td></td></tr><script type="text/javascript">
           
          Show
          ngagex Vladimir Buravtsov added a comment - - edited From Console: Function Result is missing in build script: <tr><td class= "setting-leftspace" > </td><td class= "setting-name" >Param2</td><td class= "setting-main" ><div name= "parameter" id= "choice-parameter-172075458256007" class= ""><input name=" name " type=" hidden " value=" Param2 "><div id=" formattedHtml_choice-parameter-172075458481046 ">[error]</div><input type=" text " name=" value " value=" " style=" visibility: hidden; position: absolute; "></div></td><td class=" setting-no-help "></td></tr><tr class=" validation-error-area "><td colspan=" 2 "></td><td></td><td></td></tr><script type=" text/javascript">
          Hide
          ioannis Ioannis Moutsatsos added a comment -

          I think this is happening when you put JavaScript in a parameter that gets updated due to a change form another Active Choice parameter. Try to put your JavaScript function in a separate AC that does not reference any parameters. 

          Show
          ioannis Ioannis Moutsatsos added a comment - I think this is happening when you put JavaScript in a parameter that gets updated due to a change form another Active Choice parameter. Try to put your JavaScript function in a separate AC that does not reference any parameters. 

            People

            Assignee:
            kinow Bruno P. Kinoshita
            Reporter:
            ngagex Vladimir Buravtsov
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: