Jump to content


javascript auto sum


1 reply to this topic

#1 niurexx

    Young Padawan

  • Members
  • Pip
  • 7 posts

Posted 10 December 2008 - 08:27 PM

can some tell me how to change the array value form 1..2..3..4 into [1]..[2]..[3]..[4].. from this javascript code..

var totalothertax = document.form1.totalothertax.value;
	 if (!totalothertax) {
	 totalothertax = 0.00;
	 }else{
		 var totalothertax = 0.00;
		 for (var i=1; i<=taxCount; i++ ){
		 var taxpercentid = "taxpercent"+i;
		 var taxpercent = document.getElementById(taxpercentid).value;
		 var taxamountid = "taxamount"+i;
		 var taxamount = eval(taxpercent) * eval(principalprice)/100;
			if (principalprice){
			 document.getElementById(taxamountid).value=taxamount;
			 totalothertax = totalothertax + taxamount;
			}
		 }
		 
		 document.form1.totalothertax.value=totalothertax;
	 }


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 11 December 2008 - 01:29 AM

Technically speaking, there are no array's in that code. Could you be more specific as to which value you want changed?

Note: Assuming you're simply talking about the final amount though, a simple example would be:
document.form1.totalothertax.value= '['+totalothertax+']';






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users