today we are going to show you how you can get the value of a checkbox in a html web form when submitted into javascript code:

first, open your text editor. i will use windows notepad, then copy and paste this code into a blank notepad:

<!--
############## CREATED BY WWW.WEBUNE.COM ###############
############## COPYRIGHT UGN/GPL 2010 #################
############# PLEASE DO NOT REMOVE THIS ###############
-->
<p>This small script shows you how to get the javascript value in a web form.<br /></p>

<script type="text/javascript">
function alertselected(){
	var Field = document.getElementById('sample');
 alert('selectedIndex = ' + Field.checked + ' \n value = ' + Field.value + ' \n type = ' + Field.type )
}
</script>

<form id="someform">
agree to terms: 
<input type="checkbox" id="sample" value="agree"><br />



<input type="button" onClick="alertselected()" value="alert" />
</form>

<p><img src="http://www.webune.com/images/headers/default_logo.jpg" /></p>
<p>Script Created by www.<a href="http://www.webune.com">Webune.com</a></p>


now save the file as form-checkbox.html and open it with your browser to see it in action.

if you prefer, we have already created the file for you. just download it from the attachments section


Demo

agree to terms:
form-checkbox.html