Hi
I am trying to work on a long form for calculating house contents for insurance purposes. As you can see below, my code is rediculously long and it also stops working when it gets to var a10 for some reason. ?
Is there an easier way to do this using an array? Hopefully you can see what I am trying to achieve. Thank you in advance for any asissitance. ?
function addrow(){
// Add the new items into the final total column
//assigns the current value of the input box for each row to a new variable
var a001 = (document.contents.a1.value*1);
var a002 = (document.contents.a2.value*1);
var a003 = (document.contents.a3.value*1);
var a004 = (document.contents.a4.value*1);
var a005 = (document.contents.a5.value*1);
var a006 = (document.contents.a6.value*1);
var a007 = (document.contents.a7.value*1);
var a008 = (document.contents.a8.value*1);
var a009 = (document.contents.a9.value*1);
var a010 = (document.contents.a10.value*1);
var a011 = (document.contents.a11.value*1);
var a012 = (document.contents.a12.value*1);
… and so on until 88!
//assigns the current value of the ‘total’ box for each row to a new variable
var t001 = (document.contents.t1.value*1);
var t002 = (document.contents.t2.value*1);
var t003 = (document.contents.t3.value*1);
var t004 = (document.contents.t4.value*1);
var t005 = (document.contents.t5.value*1);
var t006 = (document.contents.t6.value*1);
var t007 = (document.contents.t7.value*1);
var t008 = (document.contents.t8.value*1);
var t009 = (document.contents.t9.value*1);
var t010 = (document.contents.t10.value*1);
var t011 = (document.contents.t11.value*1);
… and so on until 88!
//adds the new entry value to the total of the row
document.contents.t1.value = (a001+=t001); // does the math
document.contents.a1.value = ”; //clears the entry box
document.contents.t2.value = (a002+=t002);
document.contents.a2.value = ”;
document.contents.t3.value = (a003+=t003);
document.contents.a3.value = ”;
document.contents.t4.value = (a004+=t004);
document.contents.a4.value = ”;
document.contents.t5.value = (a005+=t005);
document.contents.a5.value = ”;
document.contents.t6.value = (a006+=t006);
document.contents.a6.value = ”;
document.contents.t7.value = (a007+=t007);
document.contents.a7.value = ”;
document.contents.t8.value = (a008+=t008);
document.contents.a8.value = ”;
document.contents.t9.value = (a009+=t009);
document.contents.a9.value = ”;
document.contents.t10.value = (a0010+=t0010);
document.contents.a10.value = ”;
document.contents.t11.value = (a0011+=t0011);
document.contents.a11.value = ”;
document.contents.t12.value = (a0012+=t0012);
document.contents.a12.value = ”;
… and so on until 88!
}