I'm trying to change the text inside a h1 tag using the element id "greeting" and a external java script. I'm having trouble trying to figure out how to call upon my function init that has gathered variables and use them in the next function. Heres what I have so far.
HTML
<head>
<title>Matt Beckley</title>
<script type="text/javascript" src="script1.js"></script>
</head>
<body>
<h1 id="greeting">Welcome!</h1>
</body>
</html>
THE SCRIPT WHERE THE PROBLEM IS!
window.onload = init;
function init()
{
var fullname=prompt("Please Enter you name!","Anonymous ");
(fullname == "Anonymous")? "Anonymous " : "";
var nickname=prompt("Please Enter you nickname!"," None");
(nickname == "None")? " None": "";
}
function writeGreeting()
{
document.getElementById("greeting").innerHTML= ?????????
}
So I don't know how to make the last function work so that the h1 tag shows a name and a nick. w3schools only shows "Strings" and not the ability to call the other function. Anyone know how to do this?