Adding fields ... I need this 6 times ... help

I

ID10Terror

Hi:

I need to add a few fields together and get a grand total. The entire thing
works perfectly. My problem is that I need to do this to 5 other fields. I
have enclosed the code at the bottom of this. I copied and pasted the code
and changed the following "d1" to "d2", "box0" to "box1" and "total0" to
"total1". This is all beyond me and I would really appreciate any help with
my problem.

TIA

*********************************************************************************************

<html lang="en">
<head>
<title>46944</title>
<script type="text/javascript">
var txt = window.navigator.appName;
var ie = (txt == "Microsoft Internet Explorer") ? true : false;
var opera = (txt == "Opera") ? true : false;
</script>
</head>
<body>
<form>
<fieldset style="width: 243; height: 200">
<dl>
<dt><label for="1">1</label></dt>
<dd><input id="1" name="box0" type="checkbox" value="1"></dd>

<dt><label for="2">2</label></dt>
<dd><input id="2" name="box0" type="checkbox" value="2"></dd>

<dt><label for="4">4</label></dt>
<dd><input id="4" name="box0" type="checkbox" value="4"></dd>

<dt><label for="8">8</label></dt>
<dd><input id="8" name="box0" type="checkbox" value="8"></dd>
</dl>
<input id="total0" type="text" value="0">

</fieldset>
</form>
</body>

<script type="text/javascript">
var list = null;
if(ie)
{
list =
document.getElementsByTagName("dl")[0].getElementsByTagName("input");
}
else
{
list = document.getElementsByName("box0");
}

var i = 0;
for(i = 0; i < list.length; i++)
{
if(ie || opera)
{
list.onclick = create_total0;
}
else
{
list.addEventListener("click",create_total0,true);
}
}

var total0 = 0;
function create_total0()
{
total0 = 0;
for(i = 0; i < list.length; i++)
{
if(list.checked)
{
total0 += Number(list.value);
}
}
document.getElementById("total0").value = total0;
}
</script>
</html>
 
F

FrontPageForms

Hi,

I am not sure if I understand you correctly. Is what you want to
add 5 additional amounts to the existing form ( like 12,15,25 etc)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top