topical media & game development
#javascript-code-22-submit.js / js
// Bind a submit handler the the first form in the document
document.getElementsByTagName(“form”)[0].onsubmit = function(e) {
// Get the name that the user entered
var name = document.getElementById(“name”);
// Set the <h1> element to contain Hello Name! (where name is the name
// that the user entered into the form)
document.getElementsByTagName(“h1”)[0].innerHTML =
“Hello “ + name + “!”;
// Make sure that the form is not submitted to the server
return false;
};
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.