totaling fields 
Author Message
 totaling fields

Help I am trying to total 25 fields and put results into field "tot_order"  This function isn't doing it.  It also isn't returning any errors.  Java is running because other scripts work fine.  I am new to this and have looked at several sites and can't find the answer.

function totalorder() {
var tot_order = 0
  for (var x=1; x<=25; x++) {
   var ename = "Extended_" + x

   tot_order += parseFloat(document.Edit_Submit[ename].value)
  }

Quote:
}

<input type="text" value="<%= strExtended_1 %>" onChange="totalorder()" name="Extended_1">
...
<input type="text" value="<%= strExtended_25 %>" onChange="totalorder()" name="Extended_25">

<input type="text" name="tot_order" size="5">

Thanks
--
Mike Drewery

"What we have to learn to do, we learn by doing."
Aristotle



Sat, 03 May 2003 03:00:00 GMT  
 totaling fields
The line:
var ename = "Extended_" + x
should read instead:
var ename = "strExtended_" + x
according to the names that you have given the fields.

Help I am trying to total 25 fields and put results into field "tot_order"  This function isn't
doing it.  It also isn't returning any errors.  Java is running because other scripts work fine.  I
am new to this and have looked at several sites and can't find the answer.

function totalorder() {
var tot_order = 0
  for (var x=1; x<=25; x++) {
   var ename = "Extended_" + x

   tot_order += parseFloat(document.Edit_Submit[ename].value)
  }

Quote:
}

<input type="text" value="<%= strExtended_1 %>" onChange="totalorder()" name="Extended_1">
...
<input type="text" value="<%= strExtended_25 %>" onChange="totalorder()" name="Extended_25">

<input type="text" name="tot_order" size="5">

Thanks
--
Mike Drewery

"What we have to learn to do, we learn by doing."
Aristotle



Sat, 03 May 2003 03:00:00 GMT  
 totaling fields

The name is Extended_1

The value is strExtended_1 coming from some VBScript.

as users chnge the values in the Extended_x fields I want the total to
update.

Mike



Quote:
> The line:
> var ename = "Extended_" + x
> should read instead:
> var ename = "strExtended_" + x
> according to the names that you have given the fields.




Quote:
> Help I am trying to total 25 fields and put results into field "tot_order"
This function isn't
> doing it.  It also isn't returning any errors.  Java is running because

other scripts work fine.  I
Quote:
> am new to this and have looked at several sites and can't find the answer.

> function totalorder() {
> var tot_order = 0
>   for (var x=1; x<=25; x++) {
>    var ename = "Extended_" + x

>    tot_order += parseFloat(document.Edit_Submit[ename].value)
>   }

> }

> <input type="text" value="<%= strExtended_1 %>" onChange="totalorder()"
name="Extended_1">
> ...
> <input type="text" value="<%= strExtended_25 %>" onChange="totalorder()"
name="Extended_25">

> <input type="text" name="tot_order" size="5">

> Thanks
> --
> Mike Drewery

> "What we have to learn to do, we learn by doing."
> Aristotle



Sat, 03 May 2003 03:00:00 GMT  
 totaling fields

I suppose this is created from within an a asp page...(seeing the <% ... %> tags)

Here is a HTML example that does your job (just "extend" it a bit)
HTH
Joost Devos

--------------------------------------------------------------------------------

<html>
<head>
<script>
function totalorder() {
var tot_order = 0
for (var x=1; x<=3; x++) {
   var ename = "Extended_" + x
   tot_order += parseFloat(document.body.all(ename).value)
  }
document.body.all("TOT_order").value=tot_order

Quote:
}

</script>
</head>
<body>
<form name="Edit_Submit">
 <input type="text" value="1" onChange="totalorder()" name="Extended_1">
 <input type="text" value="2" onChange="totalorder()" name="Extended_2">
 <input type="text" value="3" onChange="totalorder()" name="Extended_3">
 <input type="text" name="TOT_order" size="5">
</form>
</body>
</html>

--------------------------------------------------------------------------------

  Help I am trying to total 25 fields and put results into field "tot_order"  This function isn't doing it.  It also isn't returning any errors.  Java is running because other scripts work fine.  I am new to this and have looked at several sites and can't find the answer.

  function totalorder() {
  var tot_order = 0
    for (var x=1; x<=25; x++) {
     var ename = "Extended_" + x

     tot_order += parseFloat(document.Edit_Submit[ename].value)
    }

  }

  <input type="text" value="<%= strExtended_1 %>" onChange="totalorder()" name="Extended_1">
  ...
  <input type="text" value="<%= strExtended_25 %>" onChange="totalorder()" name="Extended_25">

  <input type="text" name="tot_order" size="5">

  Thanks
  --
  Mike Drewery

  "What we have to learn to do, we learn by doing."
  Aristotle



Sat, 03 May 2003 03:00:00 GMT  
 totaling fields

Thanks for the reply.  This is what worked for me  I hadn't added the next to last line.

Thanks again
Mike

function totalorder() {
var tot_order = 0
  for (var x=1; x<=25; x++) {
   var ename = "Extended_" + x
   tot_order += parseFloat(document.Edit_Submit[ename].value)
  }
  document.Edit_Submit.tot_order.value = tot_order

Quote:
}


  I suppose this is created from within an a asp page...(seeing the <% ... %> tags)

  Here is a HTML example that does your job (just "extend" it a bit)
  HTH
  Joost Devos

------------------------------------------------------------------------------

  <html>
  <head>
  <script>
  function totalorder() {
  var tot_order = 0
  for (var x=1; x<=3; x++) {
     var ename = "Extended_" + x
     tot_order += parseFloat(document.body.all(ename).value)
    }
  document.body.all("TOT_order").value=tot_order
  }
  </script>
  </head>
  <body>
  <form name="Edit_Submit">
   <input type="text" value="1" onChange="totalorder()" name="Extended_1">
   <input type="text" value="2" onChange="totalorder()" name="Extended_2">
   <input type="text" value="3" onChange="totalorder()" name="Extended_3">
   <input type="text" name="TOT_order" size="5">
  </form>
  </body>
  </html>

------------------------------------------------------------------------------


    Help I am trying to total 25 fields and put results into field "tot_order"  This function isn't doing it.  It also isn't returning any errors.  Java is running because other scripts work fine.  I am new to this and have looked at several sites and can't find the answer.

    function totalorder() {
    var tot_order = 0
      for (var x=1; x<=25; x++) {
       var ename = "Extended_" + x

       tot_order += parseFloat(document.Edit_Submit[ename].value)
      }

    }

    <input type="text" value="<%= strExtended_1 %>" onChange="totalorder()" name="Extended_1">
    ...
    <input type="text" value="<%= strExtended_25 %>" onChange="totalorder()" name="Extended_25">

    <input type="text" name="tot_order" size="5">

    Thanks
    --
    Mike Drewery

    "What we have to learn to do, we learn by doing."
    Aristotle



Sat, 03 May 2003 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. total ink coverage

2. total newbie

3. passing fields from form to form, and handling a date field

4. Copy from fields to fields

5. Total physical memory

6. Total recordset count?

7. Total value calculation

8. Will do small programming assignments for a total 50 dollars

9. Calculating a total amount, and adding sales tax...

10. Total for Multiple Instances (Record Sets)

11. Get total from FlexGrid in VBScript

12. Total time

 

 
Powered by phpBB® Forum Software