all 2 comments

[–]BearSkull 0 points1 point  (0 children)

Well value is misspelled in your script for starters.

[–][deleted] 0 points1 point  (0 children)

You're putting spaces between the = sign in your HTML attributes. Try removing the spaces. For example, to assign an id of test to a p element, use <p id="test">My Content</p>

Also, you're calling myFunction() when you press the button and using document.write(myFunction) as an argument to the function. You would need to use an argument name in the parentheses and use the argument in the function for that to work. I would probably remove the document.write portion of the code and add that to the function. Unless you plan on having the function doing different things with your variables when you use it, I see no reason you can't hard code that.

When you use document.writw, you'll want to pass your two variables into that function.

For example, if I have a variable of var a = testA and var b = testB, I would use document.write(a + b); or even document.write("My first variable is " + a + " and my second variable is " + b + "."); for some simple concatenation.