• Resolved rob0m

    (@rob0m)


    I would like to run <Script> and add Js functions that bring “Now Playing” info from online and add it to an input (via an HTML field). (I know it sounds risky)

    I can get this info to display in an HTML element but I would like to let an HTML Button be pressed and add that data in the element.TextContent to an input.

    Forminator (understandably) strips the ‘onclick’ bit of the button tag.
    I guess I would also then need edit function/child theme or use Code Snippets etc to add the functions?
    I was testing another forms plugin and it did not seem to find <Script> tags in HTML. But I can understand this might be a security issue. OR maybe someelse I don’t understand.

    Maybe there is a better way to do it. A more secure one or something but how would I be able to call functions on the Forminator like this? Or do it with built in functionality?

    Forminator feels great.
    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @rob0m,

    Thank you for contacting us.

    Could you please provide me with the script code you were testing on your form? Please also provide additional details to on your expected workflow for brining the “Now Playing” info(which source) and which input were you thinking of adding it in case we are able to see if there are any other alternatives for it.

    Best,
    Jonathan S

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @rob0m ,

    We haven’t heard from you for a while now – seems that you were able to solve this query.

    Don’t hesitate to re-open this ticket if you still require our assistance.

    kind regards,
    Kasia

    Thread Starter rob0m

    (@rob0m)

    Hi Kasia,

    Sorry just got back round to getting my head around this again.

    On testing, I find that adding an ‘onclick=’ to an HTML button tag gets stripped.

    So:
    <button onclick="changeSubject()">Click</button>
    becomes
    <button>Click</button>
    after saving it as an HTML field in Forminator.

    So even if I have a function in the html, the ‘onclick’ will not be there to call it.

    Though, when I copy a sample of script from here:
    https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onclick

    <button onclick="myFunction()">Click me</button>
    
    <p id="demo"></p>
    
    <script>
    function myFunction() {
      document.getElementById("demo").innerHTML = "Hello World";
    }
    </script>

    It works – but the ‘onclick=’ has still been stripped.
    So it becomes
    <button>Click me</button>
    But weirdly, it still works.
    But adding my own buttons and ‘onclick=’ doesn’t seem to work.

    Don’t understand this stripping behaviour. Is this Forminator?

    Much Thanks

    Plugin Support Predrag – WPMU DEV Support

    (@wpmudev-support1)

    Hi @rob0m,

    It seems that the code is indeed stripped in editor but when checking the page source I can see that “onclick” is still there.
    I have created a report for our devs to check this further and see if it can be addressed in one of the future releases.

    Thanks for bringing this to our attention!

    Best regards,
    Predrag

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Running <script? tags in HTML block’ is closed to new replies.