Kode: Vælg alt
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Making Objects</title>
<META name="keywords" content="" />
<META name="description" content="" />
<title>Just playing around with the DOM</title>
<script language="JavaScript" type="text/JavaScript">
function processForm(){
myform = document.userDetails;
first = document.forms[0].elements[0].value;
last = document.forms[0].elements[1].value;
if (first == "Mor" && last == "Nielsen") {
alert("Hej mor :D!");
}
else if (first == "Far" && last == "Nielsen") {
alert("Hej far!")
}
else {
alert("Hej " + first + " " + last);
}
}
</script>
</head>
<body>
<form name="userDetails" onSubmit="processForm()">
<input type="text" name="fname"/>
<input type="text" name="lname"/>
<input type="submit" name="submit"/>
</form>
</body>
</html>