![]() |
Help with website
Hello, my team is working on the website and were trying to do some java script but could not get it to work could someone tell me what is wrong with this simple script.
<html> <head> </head> <body> <h1>Team #</h1> <p id="demo"></p> <button type="button" onclick="displayDate()">Display Date</button> <script type="text/javascript"> var a =1; function displayDate() { a=a+2; } if (a==1) { document.getElementById("demo").innerHTML="Hello"; } else { document.getElementById("demo").innerHTML="GoodBye "; } </script> </body> </html> |
Re: Help with website
Add a set of curly braces around the code you want in the function e.g.
Code:
var a =1;Make sense? |
Re: Help with website
First of all, you should ALWAYS begin your HTML files with a doctype.
Code:
<!DOCTYPE htmlCode:
<script type="text/javascript" src="js/index.js"></script>Second of all, I made a little demonstration snippet using JSFiddle, which can be found here: http://jsfiddle.net/ianonavy/cfHpd/ I hope this helps. Continue to post if you have further questions. |
Re: Help with website
Thank you I understand what I did wrong. You were big helps.
|
| All times are GMT -5. The time now is 17:25. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi