Forum Discussion

henry_yc's avatar
henry_yc
Ideator I
8 months ago

"This" String Becomes "srcElement"

Hi all,

I have created a form that looks like this:

The table is pre-filled via a Form Event method. This is a checklist that the user fills out for document reviews. Clicking on the New Version button triggers a Field Event method that clears the table and fills the table with fresh (but same) checklist items. However, on clicking the button and triggering the method, all instances of the string "this" becomes "srcElement".

Does anyone know why this is happening and how to prevent it?

Version 11 SP9.

Thanks!

4 Replies

  • My guess: You forgot some " or html tags somewhere. Your static text is executed as script. 

    Do you use something like this?

    htmlContent += "<td>This is my text inside a table. For this example we add a lot of words like this.</td>";

    • henry_yc's avatar
      henry_yc
      Ideator I

      I do something very similar.

      var technical_review_checklist =
          "<html>" +
              "<tbody><tr>" +
                  "<td width=\"80%\"><span style=\"font-weight: bold;\"Checklist Item</span></td>" +
                  "<td width=\"80%\"><span style=\"font-weight: bold;\"Y/N/NA</span></td>" +
              "</tr>" +
              "<tr>" +
                  "<td> 7. The level of detail in the document is suitable for this phase of development.</td>" +
                  "<td></td>" +
              "</tr>" +
              "</tbody></table>" +
          "</html>"

      Sorry about the text, it doesn't show properly when I use a code block.

      Anyway, it works properly when I use it to pre-fill the field as a Form Event, but gets weird when I use it to replace the text as a Field Event.

      • AngelaIp's avatar
        AngelaIp
        Ideator I

        The first "table" tag is missing, but I guess you reduced the code sample for this post.

        srcElement is typical for field events and as far as I know contains the field context itself. It´s like "this" for fields. 

        What exactly do you replace? Do you re-render the complete html table with the same code?
        I assume you use a html element for your custom table. What code do you use to write the table content itself?
        Something like document.getElementById("mytable").innerHTML/innerText = tableStuff ?

        And check in the browser debugger how the table looks like in native html. Maybe you find some hints for any missing tags or similiar.