I am trying to create a website on the fly using JavaScript, but cannot get my getElementById function to work correctly. I joked a bit, found examples and tried to get them to work without success (most of them did not use an external .js file). The following is the code for my JavaScript and HTML:
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Final Project</title>
<script type="text/javascript">
</script>
</head>
<body>
<script type="text/javascript" src="finalProj.js">
</script>
<form name = "myForm">
<h1 id="myHeader"></h1>
JavaScript:
var firstName = ("RicK");
var courseName = ("WEB 180");
function myHeading()
{
document.getElementById('header').write = (firstName + lastName);
}
source
share