Jump to content

howardjennings

Members
  • Posts

    2
  • Joined

  • Last visited

howardjennings's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hi I'm trying to create some java script to do some calculations on a Caldera Form. I've taken an example from one of the tutorials on this site and change a couple of the variables and now it doesn't work. Can anyone point out my mistake? I've copied the entire stuff from the example, this is my version, I've changed the 'TIME' var to 'Prop_Type' and removed the calculation and replaced it with a number. the original is at the bottom of this post. <!DOCTYPE html> <html> <body> <p>Click the button to get a time-based greeting:</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var greeting; var Prop_Type = 2; if (Prop_Type = 1) { greeting = "Apartment"; } else if (Prop_Type = 2) { greeting = "Commercial"; } else { greeting = "Residential"; } document.getElementById("demo").innerHTML = greeting; } </script> </body> </html> ORIGINAL code <!DOCTYPE html> <html> <body> <p>Click the button to get a time-based greeting:</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var greeting; var time = new Date().getHours(); if (time < 10) { greeting = "Good morning"; } else if (time < 20) { greeting = "Good day"; } else { greeting = "Good evening"; } document.getElementById("demo").innerHTML = greeting; } </script> </body> </html>
×
×
  • Create New...