Here's is some reasonably complex JavaScript and HTML -- we won't get to anything this hairy in class, but it
gives you a sense of what JavaScript can look like.
(To see what it does,
click here).
<script language="JavaScript">
<!-- Hide scripts from old browsers
function tryclear()
{
parent.frames[1].document.close();
parent.frames[1].document.open();
parent.frames[1].document.write("<h3>Explanation</h3><p> ");
}
function answer(correct,which) {
if (document.forms[0].elements[which].value == correct) {
alert("Correct!");
}
else {
alert("Try again.");
}
}
function give(correct,which) {
document.forms[0].elements[which].value = correct;
}
function explain(x,y)
{
tryclear();
parent.frames[1].document.write("The result of " );
parent.frames[1].document.write( x + " / ");
parent.frames[1].document.write( y +" is:");
parent.frames[1].document.write( Math.floor(x/y) + "remainder " + x%y);
parent.frames[1].document.write("So, the answer is: ");
parent.frames[1].document.write(" < B > " + x%y );
parent.frames[1].document.write(" < /B > ");
}
//End hide -- >
</script>