How can I call Javascript from HTMLSnippet ?

0
Hi everyone, I've got some trouble. My scenario is I created HTML that contains form to submit in HTMLSnippet #1 and I created javascript function in HTMLSnippet #2, it contained function to receive a value from HTMLSnippet #1. The first one has worked well but after I submitted it was not function. Do you have any idea? This the code in each HTMLSnippet; HTMLSnippet #1 <h1>JavaScript Can Validate Input</h1> <p>Please input a number between 1 and 10:</p> <input id="numb" type="number"/> <button type="button" onclick="myFunction()">Submit</button> <p id="demo"></p> HTMLSnippet #2 function myFunction() { var x, text; // Get the value of the input field with id="numb" x = document.getElementById("numb").value; // If x is Not a Number or less than one or greater than 10 if (isNaN(x) || x < 1 || x > 10) { text = "Input not valid"; } else { text = "Input OK"; } document.getElementById("demo").innerHTML = text; } Thank you.
asked
1 answers
0

If you really need the JavaScript + HTML, but they are dependent, you could try to put all the HTML + JS in one HTMLSnippet widget. Set the widget to HTML and add the JavaScript in between the script tags:

<script type="text/javascript">
your code;
</script>
answered