Why isn't this working
I don't understand why paragraph(demo) is not changing into "IT WORKS!!!"
Here is the script:
var firstname = document.getElementById("firstname").value;
var lastname = document.getElementById("lastname").value;
var middlename = document.getElementById("middlename").value;
alert("Hello " + firstname + " " + middlename + " " + lastname);
if (middlename == null);
getElementById("demo").innerHTML= "IT WORKS!!!";
First Name: ....<input type="text" id="firstname">
Middle Name: <input type="text" id="middlename">
Last Name: ....<input type="text" id="lastname">
<input type="button" value="Submit" onclick="submitinfo()">
<p id= "demo"></p>
I have an exact example of what you want give me a second to find it.#
<span id="demo"> <span>
Put this in your HTML Header.
Last edited by Lucas1; 10-13-2012 at 01:25 PM.
try it with
document.getElementById("demo").innerHTML= "IT WORKS!!!";
actually it's a very good habit when posting questions here to include all the relevant information (rendered html, js and css) in the one code block. It saves people having to ask to see other bits and makes it easier to test your code. Once you have your code working you can do what you like with it.
Originally Posted by Lucas1
I've never been hugely swayed by the separation of concerns arguments. If you are working on large frameworks with multiple pages depending on the same external files, of course it makes sense. But to create a separate js file for a few lines of code seems unnecessarily dogmatic.
What do you mean by :
if (middlename == null);
why null and what did you expect from that?!
try to keep it simple and do
and you're on gear.
that will never work...
seeing this: getElementById("demo").innerHTML= "IT WORKS!!!";}}</script>
First Name: ....<input type="text" id="firstname">...
I presumed he was shorting out the illustration of his problem and that on his original code stands a properly written document.getElementBy(id) instead.
Last edited by Troy III; 10-13-2012 at 02:32 PM.
My answer to this would have been 'Use the error console", but I don't like to repeat myself too often.
and how would that help against syntactically correct code but semantically wrong meaning of a chosen expression? nothing can guard you against your own laspus lingua.
It wouldn't; It wasn't.
Originally Posted by Troy III
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread