The_Unkown675 Posted March 20, 2016 Share Posted March 20, 2016 Ok, so I tried doing running the script below, and all that appeared is the button, any help? <DOCTYPE html> <html> <body> <p id="start"> </p> <button onclick="end()"> Click Me To Find 10% more than the number above</button> <p id="ending"> </p> <script> var start_value = 10000 ; document.getElementById("start").innerHTML = start_value ; var percent = start_value / 10 ; var end_value = start_value + percent ; function end() document.getElementById("ending").innerHTML = end_value ; </script> </body> </html> Link to comment Share on other sites More sharing options...
Ingolme Posted March 20, 2016 Share Posted March 20, 2016 The script worked when I tested it. What happens when you try it and what did you expect? Link to comment Share on other sites More sharing options...
dsonesuk Posted March 20, 2016 Share Posted March 20, 2016 What editor did you use? Notepad? If so make sure you save as utf8 encoded. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 21, 2016 Share Posted March 21, 2016 function end() document.getElementById("ending").innerHTML = end_value ; I don't know if brackets are optional around a one-line function since I've always used them, but if not then you're missing brackets there. Link to comment Share on other sites More sharing options...
Ingolme Posted March 21, 2016 Share Posted March 21, 2016 I tested to make sure, the function works without brackets, but I still would recommend adding them. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now