Add two numbers using javascript with html snippet.

0
i need to add two numbers using html snippet.But when i call a function to add the values,it shows an error as like this(addNumbers is not defined ReferenceError: addNumbers is not defined     at HTMLInputElement.onclick (http://localhost:8084/index.html?profile=Responsive:1:12) anyone suggest me a solution. code which i tried,  <html> <head> <title>Add program</title> <script language="javascript"> function addNumbers() { var val1 = parseInt(document.getElementById("value1").value); var val2 = parseInt(document.getElementById("value2").value); var ansD = document.getElementById("answer"); ansD.value = val1 + val2; } </script> </head> <body> value1 = <input type="text" id="value1" name="value1" value=""/> value2 = <input type="text" id="value2" name="value2" value=""/> <input type="button" name="Sumbit" value="Click here" onclick="javascript:addNumbers()"/> Answer = <input type="text" id="answer" name="answer" value=""/> </body> </html>
asked
2 answers
1

Your question leads me to believe you’re trying to solve a problem in a way that, while possible, probably isn’t the best way to do it with Mendix.

Can you take a step back and edit your question to explain the problem/functionality you’re trying to build?

answered
0

It feels like you would have more luck creating a custom widget to achieve this.

Mendix brings in the content it needs to display via JavaScript and a custom widget can hook into the workflow and run at the correct times, as well as allowing you the flexibility of setting your own HTML templates.

Take a look at the Widget Development documentation for more details. 

answered