Call event on button click


Hi All,

I’m trying to call an event when the user clicks the submit button on a Foundry form but I’m clearly too dense to figure it out by myself.

To troubleshoot my code (You can tell I’m new to this!), I have dropped some test code into an HTML stack using SCRIPT tags for the JS:

<button id="submitx">Click me</button>
document.getElementById("submitx").onclick = function() {myFunction()};

function myFunction() {
                document.getElementById("submitx").innerHTML = "YOU CLICKED ME!";

I would expect the button’s text to change to “YOU CLICKED ME!” but this has absolutely no effect in Rapidweaver Preview or the published page. However, it works perfectly when I use the same code in Coda. Can anyone please show me where I went wrong?