Skip to content

Instantly share code, notes, and snippets.

@gvinter
Created June 17, 2011 17:52
Show Gist options
  • Save gvinter/1031897 to your computer and use it in GitHub Desktop.
Save gvinter/1031897 to your computer and use it in GitHub Desktop.
JS Form and Output Excercise
<script type="text/javascript">
var person = document.getElementsByName ();
person["name"] = document.form.name.value;
person["age"] = document.form.age.value;
person["location"] = document.form.location.value;
function printPerson(data) {
document.getElementById("demo").innerHTML = person.age;
}
</script>
<form>
Name: <input type="text" name="name" /><br />
Age: <input type="text" name="age" /><br />
Location: <input type="text" name="location" /><br />
<input type="submit" value="Submit" onclick="printPerson (form)" />
</form>
<div id="demo">
</div>
<script type="text/javascript">
//function html_insert () {
// document.getElementByName(p["name"]).innerHTML = idName;
// document.getElementByName(p["age"]).innerHTML = idAge;
// document.getElementByName(p["location"]).innerHTML = idlocation;
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment