Click to See Complete Forum and Search --> : Defining values in .js src file


r2f2d2
01-06-2003, 08:17 AM
Trying to get the checkbox calculate jv script to work ...

http://javascript.internet.com/calculators/checkbox-calculator.html

... the values of the checkboxes go into a "calculate.js" file - trying to figure out how to setup this called file. Help!

TIA!

khalidali63
01-06-2003, 08:35 AM
in your head tags

put this line of code

<script language="JavaScript1.1" src="calculate.js" type="text/javascript"></script>

then in the onclck event of the button

call a function from the calculate.js file
suppose that function is called processCheckBoxes(), then here is the calculate buttons onclick event call.

onClick="processCheckBoxes()"

r2f2d2
01-06-2003, 09:05 AM
Yeah, knew that - was looking for the source code of the "calculate.js" function ... found it ...

function load()
{
window.status = "Adpated by RFD 01.06.03"
}

function count()
{
var item1price = 100;
var item2price = 100;
var item3price = 100;
var item4price = 100;

// kortti
if (calc.item1.checked){
var witem1 = document.calc.item1.value = item1price;
} else {
var witem1 = document.calc.item1.value = 0;
}

if (calc.item2.checked){
var witem2 = document.calc.item2.value = item2price;
} else {
var witem2 = document.calc.item2.value = 0;
}

// www-sivut
if (calc.item3.checked) {
var witem3 = document.calc.item3.value = item3price;
} else {
var witem3 = document.calc.item3.value = 0;
}
if (calc.item4.checked) {
var witem4 = document.calc.item4.value = item4price;
} else {
var witem4 = document.calc.item4.value = 0;
}
document.calc.pay.value = witem1 + witem2 + witem3 + witem4;
}

Thanx.