Its typically not a good idea to have inline javascript. Create a new file and place your javascript there.
You can include this this new file on your HTML page like this: <script src="myjavascriptfile.js"></script>
9 times out of 10, you should always have your javascript included last on your page (right before the closing </body> tag, as Floris stated). This is for optimal performance.
Since you're a beginner, I recommend you dive into jQuery since it'll handle much of the cross browser issues you'll encounter and its very easy to pick up.
Oh, I tried the src thing in the head tags , so it's supposed to be in body, correct?Its typically not a good idea to have inline javascript. Create a new file and place your javascript there.
You can include this this new file on your HTML page like this: <script src="myjavascriptfile.js"></script>
9 times out of 10, you should always have your javascript included last on your page (right before the closing </body> tag, as Floris stated). This is for optimal performance.
Since you're a beginner, I recommend you dive into jQuery since it'll handle much of the cross browser issues you'll encounter and its very easy to pick up.
This is for university so its finew3schools.com and focus on html5/css3 and javascript.
Learning from a book that's obsolete is not ideal.
omg thanks! i changed it to displayProverb and it worked ! not sure why i put a noun there at the end , LOLOne mistake I see when I run the script as you provided it is the following error.
As you can see, there's an unexpected end. Which made me trace back the { } .. and function is opened, but not closed.
[doublepost=1477167668][/doublepost]The other thing I noticed, is when you submit the form, that the naming of the function seems to be wrong.
Your html code refers to displayProferb, but the function in the .js file is called displayProferbNoun.
Which, upon correcting makes the script work for me.
I hope this helped. To get to the same dev tools as I have on my screenshots; it's Chrome with right click > inspect
[doublepost=1477168047][/doublepost]The other reason it might not have worked is because your .html file has a long name, but your html code refers in the <form> to <FORM NAME="proverbForm"> expecting just proverbForm.html
Make sure they match.
here's the .zip of the .html and .js as it works for me in my browser.
That's what I was thinking. But the book doesn't seem to care, so I assumed it doesn't matter, though I assume it's always good practice to include closing tags to avoid confusion?By the way, in html tags with closing tags, the closing tags are required. the <p> for example needs to be closed with </p> ~ I know the browser are forgiving, but, every issue addressed is one excluded.
Glad you got it sorted out. Have fun learning html/css/js/etc.
It's time for a new bookThat's what I was thinking. But the book doesn't seem to care, so I assumed it doesn't matter, though I assume it's always good practice to include closing tags to avoid confusion?
what made you arrive at that conclusion it's html 3.2? at university we learn 4.0.1. i'm a total novice at university.It's time for a new bookIt's also teaching you html 3.2 it seems, the focus is really on html5 and css3.
When posting simple code, it is much easier for us to understand and correct if you use an online tool like:Oh, I tried the src thing in the head tags , so it's supposed to be in body, correct?
There was no doctype where this was declared, and it quite outdated to type it all in caps and that order. Sorry if my guess was off by a version. My point that it doesnt matter indeed is only because browsers are very forgiving. Was trying to help. Javascript when more complex will not work if you search for a p id when it fails in the nesting just because there are 50 opened and one closing tag. Making debugging a more irritating job to do.what made you arrive at that conclusion it's html 3.2? at university we learn 4.0.1. i'm a total novice at university.
i think the book is years old tbh, for my own knowledge can you recommend any really new books so i can be ahead rather than behind?
[doublepost=1477244697][/doublepost]the book is "javascript for dummies", not "html for dummies"
oh of course, btw is html case sensitive?There was no doctype where this was declared, and it quite outdated to type it all in caps and that order. Sorry if my guess was off by a version. My point that it doesnt matter indeed is only because browsers are very forgiving. Was trying to help. Javascript when more complex will not work if you search for a p id when it fails in the nesting just because there are 50 opened and one closing tag. Making debugging a more irritating job to do.
w3schools.com and focus on html5/css3 and javascript.
Learning from a book that's obsolete is not ideal.
maybe after developing some programming skills, but i'm just a beginner, so i need examples rather than bits and pieces everywhere, so i know exactly what things are useful for.For javascript, not much beats MDN.
https://developer.mozilla.org/en-US/docs/Web/JavaScript
Try starting here:maybe after developing some programming skills, but i'm just a beginner, so i need examples rather than bits and pieces everywhere, so i know exactly what things are useful for.
When I was a beginner I started with MDN, the book "Javascript the good parts", and frequent visits to stack overflow. I thought the introductory and tutorials sections on MDN were pretty solid for beginners, but to each their own I suppose. Good luck with your Journey. It's a great skill to have and it's a lot of fun.maybe after developing some programming skills, but i'm just a beginner, so i need examples rather than bits and pieces everywhere, so i know exactly what things are useful for.