I have been using code supplied by MVP's to caculate the total value of checkboxes "ttl" when checked but I now need to add to this another box which adds together this total "ttl" and another variable from my ASP code can this be done in say "document.getElementById("box5").value = ttl + <%ASPVariable%>"
<script>
function calculate(inObj){
//Don't need to pass inObj here since it is not used in the function
ttl = 0
grandttl = 0
//sets the total couter to 0
allInput = document.getElementsByTagName("input")
//loads all INPUT elements into an array called "allInput"
for(x=0; x<allInput.length; x++){
//prepares to loop through the allInput array
if (allInput[x].type == "checkbox"){
//if the input type is a checkbox proceed
if (allInput[x].checked){
//if the checkbox is checked proceed
val = parseFloat(allInput[x].value)
//load the number value into a var called val
if (!isNaN(val)) ttl += val
//if val is a valid number (ie - not Not a Number) add it to the total
}
}
}
document.getElementById("box4").value = ttl
//write the total to an input with the ID box4
}
</script>
<script>
function calculate(inObj){
//Don't need to pass inObj here since it is not used in the function
ttl = 0
grandttl = 0
//sets the total couter to 0
allInput = document.getElementsByTagName("input")
//loads all INPUT elements into an array called "allInput"
for(x=0; x<allInput.length; x++){
//prepares to loop through the allInput array
if (allInput[x].type == "checkbox"){
//if the input type is a checkbox proceed
if (allInput[x].checked){
//if the checkbox is checked proceed
val = parseFloat(allInput[x].value)
//load the number value into a var called val
if (!isNaN(val)) ttl += val
//if val is a valid number (ie - not Not a Number) add it to the total
}
}
}
document.getElementById("box4").value = ttl
//write the total to an input with the ID box4
}
</script>