0

I´m trying to structure my Firebasedata using this example from Stackoverflow: Add a list item through javascript

HTML:

 First name:
    <input type="text" id="firstname">
    <br>
    <p>Your first name is: <b id='boldStuff2'></b> 
    </p>
    <p>Other people's names:</p>
    <ol id="demo"></ol>
    <input type='button' onclick='changeText2();' value='Submit' />

Fiddle

When I try to copy the code straight into my project for testing, I´m getting the error: Uncaught ReferenceError: changeText2 is not defined at HTMLInputElement.onclick"

Also, when I try to copy the code to a new Fiddle, it doesn't work.

Any help is much appreciated

Eccles
  • 394
  • 1
  • 3
  • 13

1 Answers1

1

Did you define the changeText2() function? It seems like you are not declaring this function in your code.

Try to add the code below and check if this solves your error.

function changeText2(){
    var firstname = document.getElementById('firstname').value;
    document.getElementById('boldStuff2').innerHTML = firstname;
    x.push(firstname);
    document.getElementById('demo').innerHTML = x;
}
Chava Geldzahler
  • 3,605
  • 1
  • 18
  • 32
  • 1
    Thanks for the reply. I got it working, just a stupid typo I missed in the js file... Sorry about that. – Eccles Jul 04 '17 at 21:47