Javascript code to sum up totals

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • netsurfer

    Javascript code to sum up totals

    Hi:

    I am working on a project and need assistance, and would really
    appreciate any feedback on it.

    First part I'm banging my head against the wall on is about the amounts
    of the Amount fields along the right to automatically equal the PETTY
    CASH SUB-TOTAL field. So, the amount in this PETTY CASH SUB-TOTAL
    field comes up automatically. Also, I need to have the amount in the
    TOTAL AMOUNT field come up automatically as being the sum of the PETTY
    CASH SUB-TOTAL and the PER DIEM SUB-TOTAL fields. Please see the
    following as an HTML document to see what I'm talking about. Thanks
    very much in advanced for any response.

    <html xmlns:v="urn:sc hemas-microsoft-com:vml"
    xmlns:o="urn:sc hemas-microsoft-com:office:offi ce"
    xmlns="http://www.w3.org/TR/REC-html40">

    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=windows-1252">
    <link rel="File-List" href="draft2_fi les/filelist.xml">
    <title>Name</title>
    <!--[if !mso]>
    <style>
    v\:* { behavior: url(#default#VM L) }
    o\:* { behavior: url(#default#VM L) }
    ..shape { behavior: url(#default#VM L) }
    </style>
    <![endif]--><!--[if gte mso 9]>
    <xml><o:shapede faults v:ext="edit" spidmax="1027"/>
    </xml><![endif]-->
    </head>

    <body>

    <table border="1" width="100%" id="table13">
    <tr>
    <td width="424">Nam e:&nbsp;&nbsp;& nbsp;&nbsp;&nbs p;
    <INPUT TYPE=text NAME="name_57" SIZE="20" MAXLENGTH="100"
    VALUE=""></td>
    <td width="258">Dat e:&nbsp;&nbsp;& nbsp;&nbsp;
    <INPUT TYPE=text NAME="name_58" SIZE="20" MAXLENGTH="100"
    VALUE=""></td>
    <td>Job No:&nbsp;&nbsp; &nbsp;
    <INPUT TYPE=text NAME="name_59" SIZE="20" MAXLENGTH="100"
    VALUE=""></td>
    </tr>
    </table>























    <FORM>
    <TABLE id="table14">
    <TR VALIGN="top">
    <td width="109" align="center"> DATE</td>
    <td width="121" align="center"> CODE</td>
    <td width="124" align="center"> PAID TO</td>
    <td width="120" align="center"> DESCRIPTION</td>
    <td align="center"> AMOUNT</td>
    </TR>
    <tr>
    <TD><INPUT TYPE=text NAME="name_38" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_39" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_40" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_41" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_42" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </tr>
    <tr>
    <TD><INPUT TYPE=text NAME="name_43" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_44" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_45" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_46" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_47" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </tr>
    <tr>
    <TD><INPUT TYPE=text NAME="name_48" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_49" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_50" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_51" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_52" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </tr>
    <tr>
    <TD><INPUT TYPE=text NAME="name_53" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_54" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_55" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_56" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="email_14" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </tr>
    <TR VALIGN="top">
    <TD><INPUT TYPE=text NAME="name_8" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_11" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_10" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_28" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_9" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </TR>
    <TR VALIGN="top">
    <TD><INPUT TYPE=text NAME="name_6" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_12" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_13" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_29" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_7" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </TR>
    <TR VALIGN="top">
    <TD><INPUT TYPE=text NAME="name_4" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_14" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_15" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_30" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_5" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </TR>
    <TR VALIGN="top">
    <TD><INPUT TYPE=text NAME="name_1" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_16" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_17" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_31" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="email_1" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </TR>
    <TR ID="recip_2" STYLE="DISPLAY: NONE;" VALIGN="top">
    <TD><INPUT TYPE=text NAME="email_13" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="email_12" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="email_11" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_32" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="email_10" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </TR>
    <TR ID="recip_2" STYLE="DISPLAY: NONE;" VALIGN="top">
    <TD><INPUT TYPE=text NAME="email_9" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_18" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_19" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_33" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="email_8" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </TR>
    <TR ID="recip_2" STYLE="DISPLAY: NONE;" VALIGN="top">
    <TD><INPUT TYPE=text NAME="email_6" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_20" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_21" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_34" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="email_7" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </TR>
    <TR ID="recip_2" STYLE="DISPLAY: NONE;" VALIGN="top">
    <TD><INPUT TYPE=text NAME="email_5" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_22" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_23" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_35" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="email_4" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </TR>
    <TR ID="recip_2" STYLE="DISPLAY: NONE;" VALIGN="top">
    <TD><INPUT TYPE=text NAME="name_2" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_24" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_25" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_36" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="email_2" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </TR>
    <TR ID="recip_3" STYLE="DISPLAY: NONE;" VALIGN="top">
    <TD><INPUT TYPE=text NAME="name_3" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_26" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_27" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="name_37" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    <TD><INPUT TYPE=text NAME="email_3" SIZE="20" MAXLENGTH="100"
    VALUE=""></TD>
    </TR>
    <TR><TD COLSPAN="5" ALIGN="right" CLASS="mainbody text">
    <DIV ALIGN="CENTER"> Additional Rows:
    <SELECT NAME="recip_num b" ONCHANGE="revea l(this);">
    <OPTION VALUE="1" SELECTED> 0</OPTION>
    <OPTION VALUE="2"> 1</OPTION>
    <OPTION VALUE="3"> 2</OPTION>
    <!--OPTION VALUE="4"> 4</OPTION>
    <OPTION VALUE="5"> 5</OPTION-->
    </SELECT>
    </DIV>
    </TD>
    </TR>
    </TABLE>
    </FORM>
    <SCRIPT LANGUAGE="JavaS cript" type="text/javascript">
    function reveal(s) {
    var val = s.options[s.selectedIndex].value;
    if (val > 1) {
    for (var i = 2; i <= val; i++) {
    if (document.getEl ementById) {
    document.getEle mentById('recip _' + i).style.displa y = '';
    } else if (document.all) {
    document.all['recip_' + i].style.display = '';
    }
    }
    } else {
    for (var i = s.options.lengt h; i > 1; i--) {
    if (document.getEl ementById) {
    document.getEle mentById('recip _' + i).style.displa y = 'none';
    } else if (document.all) {
    document.all['recip_' + i].style.display = 'none';
    }
    }
    }

    }


    </SCRIPT> <tr>
    <td width="103">&nb sp;</td>
    <td width="119">&nb sp;</td>
    <td width="123">&nb sp;</td>
    <td width="117">&nb sp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>&nbsp;</DIV>
    <table x:str border=0 cellpadding=0 cellspacing=0
    style='border-collapse:
    collapse;table-layout:fixed;wi dth:741px' id="table15">
    <tr height=25 style='mso-height-source:userset; height:18.95pt' >
    <td colspan=3 style='border:m edium none; padding:0px;
    height:19px;mso-ignore:colspan; color:windowtex t; font-size:10.0pt;
    font-weight:400; font-style:normal; text-decoration:none ;
    font-family:Arial; text-align:general; vertical-align:bottom;
    white-space:nowrap'></td>
    <td style="font-weight: 700; font-family: Arial, sans-serif;
    text-align: center; color: windowtext; font-size: 10.0pt; font-style:
    normal; text-decoration: none; vertical-align: bottom; white-space:
    nowrap; border-left: .5pt solid windowtext; border-right: 1.0pt solid
    windowtext; border-top: .5pt solid windowtext; border-bottom: medium
    none; padding: 0px" width="247" height="19">PET TY CASH SUB-TOTAL</td>
    <td style='border-right:1.0pt solid windowtext; border-top:1.0pt
    solid windowtext; border-bottom:medium none; padding:0px;
    border-left:medium none; font-size:12.0pt; font-weight:700;
    font-style:italic; font-family:Arial, sans-serif; text-align:left;
    color:windowtex t; text-decoration:none ; vertical-align:bottom;
    white-space:nowrap' x:str="$" width="256" height="19"><sp an
    style='mso-spacerun:yes'> </span>$<span
    style='mso-spacerun:yes'> </span></td>
    </tr>
    <tr height=25 style='mso-height-source:userset; height:18.95pt' >
    <td colspan=5 style='border-left:medium none; border-right:medium
    none; border-top:.5pt solid windowtext; border-bottom:.5pt solid
    windowtext; padding:0px; background:silv er; height:31px;
    color:windowtex t; font-size:10.0pt; font-weight:400; font-style:normal;
    text-decoration:none ; font-family:Arial; text-align:general;
    vertical-align:bottom; white-space:nowrap'>& nbsp;</td>
    </tr>
    <tr class=xl28 height=25
    style='mso-height-source:userset; height:18.95pt' >
    <td colspan=5 height=25 style='border-left:medium none;
    border-top:medium none; border-bottom:medium none; padding:0px;
    border-right:.5pt solid black; height:18.95pt; width:740px;
    color:windowtex t; font-size:10.0pt; font-weight:400; font-style:normal;
    text-decoration:none ; font-family:Arial; text-align:general;
    vertical-align:bottom; white-space:nowrap' align=left
    valign=top><!--[if gte vml 1]><v:line id="_x0000_s102 5"

    style='position :absolute;left: 0;text-align:left;top: 0;flip:x;z-index:1'
    from="562.5pt,4 56.75pt" to="562.5pt,962 .25pt" strokecolor="wi ndowText"
    o:insetmode="au to"/><![endif]--><![if !vml]><span
    style='mso-ignore:vglayout ;
    position:absolu te;z-index:1;left:74 9px;top:608px;w idth:2px;height :676px'><img
    width=2 height=676 src="draft23_fi les/image001.gif"
    v:shapes="_x000 0_s1025"></span><![endif]><span
    style='mso-ignore:vglayout 2'><table cellpadding=0 cellspacing=0
    id="table16" width="741" height="64">
    <tr>
    <td style='border-left:.5pt solid windowtext; border-top:medium
    none; border-bottom:1.0pt solid windowtext; padding:0px;
    border-right:.5pt solid black; height:64px;wid th:739px;
    font-size:14.0pt; font-weight:700; font-family:Arial, sans-serif;
    text-align:center; white-space:normal; color:windowtex t;
    font-style:normal; text-decoration:none ; vertical-align:bottom'>P ER
    DIEM<p>&nbsp;</td>
    </tr>
    </table>
    </span></td>
    </tr>
    <tr height=25 style='mso-height-source:userset; height:18.95pt' >
    <td rowspan=4 height=100 style='border:m edium none; padding:0px;
    background:silv er; height:75.8pt;c olor:windowtext ; font-size:10.0pt;
    font-weight:400; font-style:normal; text-decoration:none ;
    font-family:Arial; text-align:general; vertical-align:bottom;
    white-space:nowrap' width="80">&nbs p;</td>
    <td style='border-left:.5pt solid windowtext; border-right:1.0pt
    solid windowtext; border-top:medium none; border-bottom:.5pt solid
    windowtext; padding:0px; width:80px; font-weight:700;
    font-style:italic; font-family:Arial, sans-serif; text-align:center;
    white-space:normal; color:windowtex t; font-size:10.0pt;
    text-decoration:none ; vertical-align:bottom'>D ATE</td>
    <td align=left valign=top style="color: windowtext; font-size:
    10.0pt; font-weight: 400; font-style: normal; text-decoration: none;
    font-family: Arial; text-align: general; vertical-align: bottom;
    white-space: nowrap; border: medium none; padding: 0px" width="325"
    colspan="2" rowspan="4">
    <table border="1" width="100%" id="table17" cellspacing="0"
    cellpadding="0" bordercolorligh t="#000000" height="120">
    <tr>
    <td width="42" align="center" height="30">&nb sp;</td>
    <td width="43" align="center" height="30"><b> &nbsp; </b></td>
    <td width="44" align="center" height="30">&nb sp;</td>
    <td width="44" align="center" height="30">&nb sp;</td>
    <td width="45" align="center" height="30">&nb sp;</td>
    <td width="40" align="center" height="30">&nb sp;</td>
    <td align="center" height="30">&nb sp;</td>
    </tr>
    <tr>
    <td width="42" height="30" align="center"> <b><font
    size="2">THUR.</font></b></td>
    <td height="30" width="43" align="center"> <b><font
    size="2">FRI.</font></b></td>
    <td height="30" width="44" align="center"> <b><font
    size="2">SAT.</font></b></td>
    <td height="30" width="44" align="center"> <b><font
    size="2">SUN.</font></b></td>
    <td height="30" width="45" align="center"> <b><font
    size="2">MON.</font></b></td>
    <td height="30" width="40" align="center"> <b><font
    size="2">TUES.</font></b></td>
    <td height="30" align="center"> <b><font
    size="2">WED.</font></b></td>
    </tr>
    <tr>
    <td width="42" height="30">&nb sp;</td>
    <td height="30" width="43">&nbs p;</td>
    <td height="30" width="44">&nbs p;</td>
    <td height="30" width="44">&nbs p;</td>
    <td height="30" width="45">&nbs p;</td>
    <td height="30" width="40">&nbs p;</td>
    <td height="30">&nb sp;</td>
    </tr>
    <tr>
    <td width="42" height="28">&nb sp;</td>
    <td height="28" width="43">&nbs p;</td>
    <td height="28" width="44">&nbs p;</td>
    <td height="28" width="44">&nbs p;</td>
    <td height="28" width="45">&nbs p;</td>
    <td height="28" width="40">&nbs p;</td>
    <td height="28">&nb sp;</td>
    </tr>
    </table>
    </td>
    <td rowspan=4 style='border:m edium none; padding:0px;
    background:silv er; color:windowtex t; font-size:10.0pt; font-weight:400;
    font-style:normal; text-decoration:none ; font-family:Arial;
    text-align:general; vertical-align:bottom; white-space:nowrap'
    width="256">&nb sp;</td>
    </tr>
    <tr height=25 style='mso-height-source:userset; height:18.95pt' >
    <td height=25 style='border-left:.5pt solid windowtext;
    border-right:1.0pt solid windowtext; border-top:medium none;
    border-bottom:.5pt solid windowtext; padding:0px;
    height:18.95pt; width:80px; font-weight:700; font-style:italic;
    font-family:Arial, sans-serif; text-align:center; white-space:normal;
    color:windowtex t; font-size:10.0pt; text-decoration:none ;
    vertical-align:bottom'>D AY</td>
    </tr>
    <tr height=25 style='mso-height-source:userset; height:18.95pt' >
    <td height=25 style='border-left:.5pt solid windowtext;
    border-right:1.0pt solid windowtext; border-bottom:.5pt solid
    windowtext; padding:0px; height:18.95pt; border-top:medium none; ;
    font-weight:700; font-style:italic; font-family:Arial, sans-serif;
    text-align:center; color:windowtex t; font-size:10.0pt;
    text-decoration:none ; vertical-align:bottom; white-space:nowrap'
    width="80">ROOM </td>
    </tr>
    <tr height=25 style='mso-height-source:userset; height:18.95pt' >
    <td height=25 style='border-left:.5pt solid windowtext;
    border-right:1.0pt solid windowtext; border-top:medium none;
    border-bottom:1.0pt solid windowtext; padding:0px; height:18.95pt;
    font-weight:700; font-style:italic; font-family:Arial, sans-serif;
    text-align:center; color:windowtex t; font-size:10.0pt;
    text-decoration:none ; vertical-align:bottom; white-space:nowrap'
    width="80">BOAR D</td>
    </tr>
    <tr height=25 style='mso-height-source:userset; height:18.95pt' >
    <td colspan=3 rowspan=4 height=107 style='border-left:medium none;
    border-top:1.0pt solid windowtext; border-bottom:medium none;
    padding:0px; background:silv er; border-right:.5pt solid black;
    height:80.85pt; color:windowtex t; font-size:10.0pt; font-weight:400;
    font-style:normal; text-decoration:none ; font-family:Arial;
    text-align:general; vertical-align:bottom;
    white-space:nowrap'>& nbsp;</td>
    <td colspan=2 style='border-top:medium none; border-bottom:1.0pt
    solid windowtext; padding:0px; background:silv er; border-right:1.0pt
    solid black; border-left:medium none; color:windowtex t;
    font-size:10.0pt; font-weight:400; font-style:normal;
    text-decoration:none ; font-family:Arial; text-align:general;
    vertical-align:bottom; white-space:nowrap'>& nbsp;</td>
    </tr>
    <tr height=25 style='mso-height-source:userset; height:18.95pt' >
    <td height=25 style='border-left:medium none; border-right:medium
    none; border-top:medium none; border-bottom:1.0pt solid windowtext;
    padding:0px; height:18.95pt; font-size:12.0pt; font-weight:700;
    font-family:Arial, sans-serif; text-align:center; color:windowtex t;
    font-style:normal; text-decoration:none ; vertical-align:bottom;
    white-space:nowrap' width="245">PER DIEM SUB-TOTAL</td>
    <td style='border-left:1.0pt solid windowtext; border-right:1.0pt
    solid windowtext; border-bottom:1.0pt solid windowtext; padding:0px;
    border-top:medium none; font-size:12.0pt; font-weight:700;
    font-style:italic; font-family:Arial, sans-serif; text-align:left;
    color:windowtex t; text-decoration:none ; vertical-align:bottom;
    white-space:nowrap' x:str="$" width="257"><sp an
    style='mso-spacerun:yes'> </span>$<span
    style='mso-spacerun:yes'> </span></td>
    </tr>
    <tr height=25 style='mso-height-source:userset; height:18.95pt' >
    <td colspan=2 height=25 style='border-top:medium none;
    border-bottom:1.0pt solid windowtext; padding:0px; background:silv er;
    border-right:1.0pt solid black; height:18.95pt; border-left:medium none;
    ; color:windowtex t; font-size:10.0pt; font-weight:400;
    font-style:normal; text-decoration:none ; font-family:Arial;
    text-align:general; vertical-align:bottom;
    white-space:nowrap'>& nbsp;</td>
    </tr>
    <tr height=32 style='mso-height-source:userset; height:24.0pt'>
    <td height=32 style='border:m edium none; padding:0px; height:24.0pt;
    font-size:12.0pt; font-weight:700; font-style:italic;
    font-family:Arial, sans-serif; text-align:center; color:windowtex t;
    text-decoration:none ; vertical-align:bottom; white-space:nowrap'
    width="245">TOT AL AMOUNT</td>
    <td style='border-left:1.0pt solid windowtext; border-right:1.0pt
    solid windowtext; border-bottom:medium none; padding:0px;
    border-top:medium none; font-size:12.0pt; font-weight:700;
    font-style:italic; font-family:Arial, sans-serif; text-align:left;
    color:windowtex t; text-decoration:none ; vertical-align:bottom;
    white-space:nowrap' x:str="$" width="257"><sp an
    style='mso-spacerun:yes'> </span>$<span
    style='mso-spacerun:yes'> </span></td>
    </tr>
    <tr height=25 style='mso-height-source:userset; height:18.95pt' >
    <td colspan=5 height=25 style='border-left:1.0pt solid windowtext;
    border-top:1.0pt solid windowtext; border-bottom:1.0pt solid
    windowtext; padding:0px; background:silv er; border-right:1.0pt solid
    black; height:18.95pt; font-weight:700; font-style:italic;
    font-family:Arial, sans-serif; text-align:center; color:windowtex t;
    font-size:10.0pt; text-decoration:none ; vertical-align:bottom;
    white-space:nowrap'>& nbsp;</td>
    </tr>
    </table>

    <p><!--[if gte vml 1]><v:line
    id="_x0000_s102 6"
    style='position :absolute;left: 0;text-align:left;top: 0;
    z-index:1' from="8.25pt,51 3pt" to="127.5pt,513 pt"
    strokecolor="wi ndowText"
    o:insetmode="au to"/><![endif]--><![if !vml]><span
    style='mso-ignore:vglayout ;
    position:absolu te;z-index:1;left:10 px;top:683px;wi dth:161px;heigh t:2px'><img
    width=161 height=2 src="draft23_fi les/image002.gif"
    v:shapes="_x000 0_s1026"></span><![endif]></p>
    <p>&nbsp;</p>

    </body>

    </html>

  • John Doe

    #2
    Re: Javascript code to sum up totals

    Get rid of all the microshaft code and ask again.

    A generic answer that doesn't require looking at that eyesore
    that you erroniously call an HTML document (If you can't apply
    this solution to your problem, don't ask for more help 'til you
    clean up your code):

    <script type="text/javascript">
    function totalfields(f1, f2,total) {
    var totfld=document .getElementById (total);
    var totval=0;
    if ( typeof(f2) == "number" ) {
    for(i=1;i<=f2;i ++) {
    el = document.getEle mentById(f1+i)
    if (! isNaN(parseFloa t(el.value))) {
    totval += parseFloat(el.v alue);
    }
    }
    totfld.value=to tval;
    } else {
    if ( isNaN(parseFloa t(document.getE lementById(f1). value)) || isNaN(parseFloa t(document.getE lementById(f2). value)) ) {
    } else {
    totfld.value=pa rseFloat(docume nt.getElementBy Id(f1).value)+p arseFloat(docum ent.getElementB yId(f2).value);
    }
    }
    totfld.onchange ();
    }
    </script>
    <INPUT TYPE=text ID=Amount1 Name=Amount1 Value="" onchange="total fields('Amount' ,2,'PettyCashSu b');">
    <INPUT TYPE=text ID=Amount2 Name=Amount2 Value="" onchange="total fields('Amount' ,2,'PettyCashSu b');">
    <INPUT TYPE=text ID=PettyCashSub Name=PettyCash Value="" DISABLED READONLY onchange="total fields('PettyCa shSub','PerDium Sub','Total');" ><br>
    <INPUT TYPE=text ID=PerDium1 Name=PerDium1 Value="" onchange="total fields('PerDium ',3,'PerDiumSub ');">
    <INPUT TYPE=text ID=PerDium2 Name=PerDium2 Value="" onchange="total fields('PerDium ',3,'PerDiumSub ');">
    <INPUT TYPE=text ID=PerDium3 Name=PerDium3 Value="" onchange="total fields('PerDium ',3,'PerDiumSub ');">
    <INPUT TYPE=text ID=PerDiumSub Name=PerDiumSub Value="" DISABLED READONLY onchange="total fields('PettyCa shSub','PerDium Sub','Total');" ><br>
    <INPUT TYPE=text ID=Total Name=Total Value="" DISABLED READONLY> <br>

    In article <1107790119.414 826.88010@l41g2 000cwc.googlegr oups.com>, netsurfer802@ya hoo.com says...[color=blue]
    > Hi:
    >
    > I am working on a project and need assistance, and would really
    > appreciate any feedback on it.
    >
    > First part I'm banging my head against the wall on is about the amounts
    > of the Amount fields along the right to automatically equal the PETTY
    > CASH SUB-TOTAL field. So, the amount in this PETTY CASH SUB-TOTAL
    > field comes up automatically. Also, I need to have the amount in the
    > TOTAL AMOUNT field come up automatically as being the sum of the PETTY
    > CASH SUB-TOTAL and the PER DIEM SUB-TOTAL fields. Please see the
    > following as an HTML document to see what I'm talking about. Thanks
    > very much in advanced for any response.
    >
    > <html xmlns:v="urn:sc hemas-microsoft-com:vml"
    > xmlns:o="urn:sc hemas-microsoft-com:office:offi ce"
    > xmlns="http://www.w3.org/TR/REC-html40">
    >
    > <head>
    > <meta http-equiv="Content-Type" content="text/html;
    > charset=windows-1252">
    > <link rel="File-List" href="draft2_fi les/filelist.xml">
    > <title>Name</title>
    > <!--[if !mso]>
    > <style>
    > v\:* { behavior: url(#default#VM L) }
    > o\:* { behavior: url(#default#VM L) }
    > .shape { behavior: url(#default#VM L) }
    > </style>
    > <![endif]--><!--[if gte mso 9]>
    > <xml><o:shapede faults v:ext="edit" spidmax="1027"/>
    > </xml><![endif]-->
    > </head>
    >
    > <body>
    >
    > <table border="1" width="100%" id="table13">
    > <tr>
    > <td width="424">Nam e:&nbsp;&nbsp;& nbsp;&nbsp;&nbs p;
    > <INPUT TYPE=text NAME="name_57" SIZE="20" MAXLENGTH="100"
    > VALUE=""></td>
    > <td width="258">Dat e:&nbsp;&nbsp;& nbsp;&nbsp;
    > <INPUT TYPE=text NAME="name_58" SIZE="20" MAXLENGTH="100"
    > VALUE=""></td>
    > <td>Job No:&nbsp;&nbsp; &nbsp;
    > <INPUT TYPE=text NAME="name_59" SIZE="20" MAXLENGTH="100"
    > VALUE=""></td>
    > </tr>
    > </table>
    >[/color]

    Comment

    • netsurfer

      #3
      Re: Javascript code to sum up totals

      ok let's use the generic answer...and thanks for responding...it works
      but
      it keeps saying
      "Object doesn't support this property or method" on the line that says
      and in the script debugger I have it points to the line:

      totfld.onchange ( );

      Otherwise it works.

      Comment

      • Fred Oz

        #4
        Re: Javascript code to sum up totals

        netsurfer wrote:[color=blue]
        > ok let's use the generic answer...and thanks for responding...it works
        > but
        > it keeps saying
        > "Object doesn't support this property or method" on the line that says
        > and in the script debugger I have it points to the line:
        >
        > totfld.onchange ( );
        >
        > Otherwise it works.
        >[/color]

        The error in this line:

        var totfld=document .getElementById (total);

        is because "total" is supposed to match the element id in the
        input below.

        <INPUT TYPE=text ID=Total Name=Total Value="" DISABLED READONLY>

        So either make the element id="total" or change the line to be

        ...getElementBy Id('Total');

        Incidentally, quote all attributes and there is no need to make
        an input disabled *and* readonly. A readonly input can't be
        modified by the user, so there's not much point in also
        disabling it.

        If your intention is to prevent the field from being submitted
        with the form, then don't use a text input as an output field,
        use an element that can contain a text node, such as <span>,
        <div> or <p>.

        Also, there is no point in giving a form element both a name and
        an id. Using just a name is all that is required, then you can
        access it through the forms collection rather than
        getElementById.


        --
        Fred

        Comment

        Working...