<div class="p-2">
<form onsubmit="return handleData()" method="post" action="https://postman-echo.com/post">
<p>Select all the scripting languages you know:</p>
<div>
<input type="checkbox" name="langs" id="langs_javascript" value="JavaScript" checked> <label for="langs_javascript">JavaScript</label>
</div>
<div>
<input type="checkbox" name="langs" id="langs_perl" value="Perl"> <label for="langs_perl">Perl</label>
</div>
<div>
<input type="checkbox" name="langs" id="langs_php" value="PHP" checked> <label for="langs_php">PHP</label>
</div>
<div>
<input type="checkbox" name="langs" id="langs_ruby" value="Ruby"> <label for="langs_ruby">Ruby</label>
</div>
<div>
<input type="submit" name="submit" value="Submit"/>
</div>
</form>
</div>
function handleData()
{
var form_data = new FormData(document.querySelector("form"));
console.log("form data: ");
for(var pair of form_data.entries())
{
console.log(pair[0]+ ' : '+ pair[1]);
}
return true;
}
This Pen doesn't use any external JavaScript resources.