JSFiddle - React, Tailwind, and code Playground
by Alex Azuero
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Demo: Using getElementById to get the elements in a form</title>
<script>
function processFormData()
{
var inputs = document.getElementsByTagName('input');
var message = 'The form has the following input elements: \n\n';
for (var i = 0; i < inputs.length; i++) {
message += inputs[i].tagName + " element with 'type' attribute = '" + inputs[i].getAttribute('type') + "' and 'name' attribute = '" + inputs[i].getAttribute('name') + "'\n";
}
alert(message);
}
</script>
</head>
<body>
<form name ="subscribe" id="subscribe_frm" action="#">
<div>
<p><label for="name">Your Name: </label><input type="text" name="name" id="txt_name"></p>
<p><label for="email">Your Email: </label><input type="text" name="email" id="txt_email"></p>
<p><label for="mail_format">Mail Format: <select name="mail_format" id="slt_mail_format">
<option value="TEXT">Plain Text</option>
<option value="HTML">HTML</option>
</select></p>
<p><input type="button" name="submit" value="submit" onclick="processFormData();" ></p>
</div>
</form>