Can't seem to get this coding correct. The function never is carried out when the button its pressed. Any help will be appreciated.
<!DOCTYPE html>
<html>
<head>
<script>
function MadLib(){
var a1 = document.AgentID.elements[0].value;
var a2 = document.City.elements[0].value;
var a3 = document.Country.elements[0].value;
var a4 = document.Utensil.elements[0].value;
var a5 = document.Adj1.elements[0].value;
var a6 = document.Animal.elements[0].value;
var a7 = document.Transportation.elements[0].value;
document.write("Agent"+a1+",");
document.write("<br>"+"<br>");
document.write("Congradulations on accepting your next assignment Agent "+a1+"");
document.write("<br>"+"<br>")
document.write("Your flight leaves to "+a2+" , "+a3+" in the next eight hours. You have been granted your weapon of choice, the "+a5+" "+a4+". Your assignment is to capture the "+a6+" with minimal casualties. Your extraction via "+a7+" will be waiting.");
document.write("<br>"+"<br>");
document.write("Best of Luck Agent "+a1+"",);
document.write("<br>");
document.write("Operations HQ");
}
</script>
</head>
<body>
<form name="AgentID">
AgentID
<input type="text">
</form>
<form name="City">
City
<input type="text">
</form>
<form name="Country">
Country
<input type="text">
</form>
<form name="Utensil">
Noun
<input type="text">
</form>
<form name="Adj1">
Adjective
<input type="text">
</form>
<form name="Animal">
Animal
<input type="text">
</form>
<form name="Transportaion">
Transportation
<input type="text">
</form>
<input type="button" value="Accept Your Mission" onClick="MadLib()">
</body>
</html>