This javascript will help you to generate the autosum when changes made in the checkbox.
Features
a) You can generate the sum when changes made in the checkbox using javascript
b) Simple and ease of use.
c) Just copy the code into your page and use it.
Preview
Code
Javascript
<!--Script by hscripts.com-->
<!--Copywrite of HIOXINDIA-->
<!--More scripts @ http://hscripts.com-->
<script type="text/javascript">
var a=10; //set the value of first textbox.
var b=20; //set the value of second textbox.
var c=30; //set the value of third textbox.
function app()
{
if(frm.chk1.checked==true)
frm.txt.value=a;
else
frm.txt.value=0;
if(frm.chk2.checked==true)
frm.txt1.value=b;
else
frm.txt1.value=0;
if(frm.chk3.checked==true)
frm.txt2.value=c;
else
frm.txt2.value=0;
var sum;
if(frm.chk1.checked || frm.chk2.checked || frm.chk3.checked==true)
{
x=parseInt(frm.txt.value);
y=parseInt(frm.txt1.value);
z=parseInt(frm.txt2.value);
sum=x+y+z;
frm.txt3.value=sum;
}
else
frm.txt3.value=0;
}
</script>
<!--Script by hscripts.com-->
For customization of this script or any script development, contact us at support@hscripts.com
Usage
a)This script is useful for generating the autosum if you click the checkbox.
b)The function app() is called to assign the value to the text box. If you click the checkbox the value will be assigned and then added. The result will be displayed in the result field.
c)To Set the values of textbox, just change the value of variables.
Example: var a=10;//set value of first textbox.
d)Copy the code into your page and use it.
License
- The javascript (misspelled as java script) is given under GPL License
- i.e. Free use for those who use the codes as it is.
- Free, if your modification does not remove our copyright information and links.
- Click Here for detailed license information.
- You can purchase the script if your requirements does not meet our GPL License terms.