1
0
-1

I tried putting this in my custom HTML field:

<script language='text/javascript'>
$(document).ready( function() {
alert('testing!');
console.log("is this even happening?");
} );


function formbuilderOnReady(){
// initialize the form field value here
alert('testing 2!');
console.log("is this even happening? 2");
}

</script>

But nothing is getting printed out to my JS console and the alerts aren't even coming up either. I took both of these examples from online - I just want the JS to run on form load but it doesn't look like it is? Any ideas? Am I forgetting something very important?  

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      Hi Stephanie,

      Sorry for the confusion!

      I did use your <script>...</script> container and just typed-in my JavaScript there.

      I just noticed that it said:

      <script language='text/javascript'>

      instead of the expected

      <script type="text/javascript"> 

      It is to be noted that the attribute 'language' has been deprecated and the 'type' attribute replaced it in HTML 4.0.

      I'm still not sure why it would run in the Form Builder and not in the Runtime Userview. Perhaps the runtime contains too many scripts that happen to be conflicting and in turn confuses the browser.

      I've edited my answer above.

      Hope it works now!

       

      Thanks,

      Ashutosh

      1. Stephanie

        That did the trick! Thank you :)

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hi there!

      The following works for me though:

      <script type='text/javascript'>
      $(function(){	// Shorthand for $( document ).ready()
      	alert("Alert!");
      	console.log("Logging into the console...");
      });
      </script>

       

      Let me know if this helps!

      Thanks,

      Ashutosh

      1. Stephanie

        Hi Ashutosh, I tried replacing my JS with your code, but it still is only coming up in the form designer (not when I publish and actually run the form.) Could you tell me what version of Joget you are using? I am also getting this error in the console - but that's all that prints. No message for me :( Failed to load resource: the server responded with a status of 404 (Not Found): http://localhost:8080/jw/js/jquery/jquery.min.map

      CommentAdd your comment...