I've got a simple I've made still not finished I still have to make a check for empty fields, I just need this... I have various check boxes and text forms, but i would like to use the same function for them all!!
And i did it exept the total field i don't know how to make it work without defining an expecific text box... Here's the code
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
var s;
function calculate(val,q,p) {
if (val == true) {
s = q*p;
document.formT.total.value = s;
}
}
</script>
</head>
<body><form name="formT">
<input type="checkbox" name="cb" onclick="calculate(formT.cb.checked,formT.quantidade.value,formT.preco.value);"/>
<input type="text" name="quantidade" />
<input type="text" name="preco" />
<input type="text" name="total" />
</form>
<form name="formR">
<input type="checkbox" name="cb" onclick="calculate(formR.cb.checked,formR.quantidade.value,formR.preco.value);"/>
<input type="text" name="quantidade" />
<input type="text" name="preco" />
<input type="text" name="total" />
</form>
</body>
</html>
what can I do with the document.formT.total.value = s; so that the function works too for the formR... I don't know If I've been clear...