Welcome visitor
* Login
* Register
It is currently September 19th, 2019, 4:44 pm
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » JavaScript



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  add a form and populate the total box
PostPosted: July 23rd, 2009, 3:17 am 
User avatar

Posts: 70
i have a form that i use on a shopping cart. On the bottom of it there's a total box which will add the prices of the selected items and because it is on the bottom of the page i have an alternative total box fixed on the top of the page but i dont know how to populate this according to what is on the original total box.
Can anyone help me please?


Top
 Profile  
 
  Re: add a form and populate the total box
PostPosted: July 23rd, 2009, 5:11 am 
User avatar

Posts: 79
<style>
#totaltop{position: fixed; top:20px; right: 20px;}
</style>

<script type="text/javascript">
var i=0;
var t=0;
var x=0;
var values = new Array();
  values[0]=0;
  values[1]=0;
  values[2]=0;
function sum(el){
  x=document.getElementById(el).value;
  x=x*1;
  values[el.substr(1)]=x;
  for (i in values){
    t+=values[i];}
  document.getElementById('total').value=t;
  document.getElementById('totaltop').value=t;
  t=0;}
</script>

<form name="form">
<input id="a0" onkeyup="sum(id);" /><br />
<input id="a1" onkeyup="sum(id);" /><br />
<input id="a2" onkeyup="sum(id);" /><br />
<input id="total" readonly="readonly" /><br />
<input id="totaltop" readonly="readonly" /><br />
</form>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » JavaScript


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron