
<!--

// *****************************************************************************
// *
// *   Script Description: 
// *        this script open a new browser window and generate Dynamic HTML code by calling
// *        function GetData(...) thats
// *         - creates <No. of Text fields> to collect numeric data with auto-total
// *         - returns Total postback to main window < return field pointer> 
// *         - set decimal places manually in the script
// *
// *   Function Syntax :
// *        Function GetData( <no of fields>, <return field pointer>, <title of window / document>)
// *
// *
// *************************************************************************

function GetData(mf_obj, ow_fld, title) {

    
    nofld=mf_obj.value
    decPlaces=2  // set decimal places

    nw=window.open("", "Gdata", "width=350,height=500,top=100,left=200,scrollbarS")
    nw.opener=self
    tnw=nw.document

    newbcolor="#ffffcc"
    newfcolor="#000000"

    HTMLstring ='<SCR' + 'IPT LANGUAGE="JavaScript">\n'
    HTMLstring +='<!--\n'

    HTMLstring +='funct' + 'ion UpdateTotal(' + ')\n'
    HTMLstring +='{\n'
    HTMLstring +='var fldname=""\n'
    HTMLstring +='var totAmt=0\n'
    HTMLstring +='frm= document.Rcpts;\n'
    HTMLstring +='t=frm.elements.length;\n'
    HTMLstring +='for (i=0;i<t;i++) {\n'
    HTMLstring +='fldname=frm(i).name\n'
  
    HTMLstring +='if (fldname.indexOf("txRD")>=0 ) {\n'
    HTMLstring +='totAmt= totAmt + Number(frm(i).value);\n'
    HTMLstring +='}\n'
    HTMLstring +='};\n'
    HTMLstring +='document.Rcpts.RcptTotal.value=totAmt.toFixed(' + decPlaces + ')\n'
    HTMLstring +='}\n'

    HTMLstring +='-->\n'
    HTMLstring +='<\/scr' + 'ipt>\n'


    HTMLstring +='<HTML>\n'
    HTMLstring +='<HEAD>\n'
    HTMLstring +='<TITLE>' + title +'</TITLE>\n'
    HTMLstring +='</HEAD>\n'
    HTMLstring +='<BODY bgColor="'+newbcolor+'">\n'
//    HTMLstring +='<P Style="font-family:arial, san serif; color:'+newfcolor+'"><u><b>'+ title +'</b></u><br><br>\n'
    
    HTMLstring +='<fieldset><legend style="font-family:arial;color:gray;font-size=12">' + title + '&nbsp;</legend><br>\n'
    HTMLstring +='<P Style="font-family:arial, san serif; color:'+newfcolor+'">\n'
    HTMLstring +='<form name="Rcpts" action="MainRcpt.asp" method="post" onSubmit="NxtFld();return false">\n'
    HTMLstring +='<table width="300">\n'
    HTMLstring +='<tr><td>&nbsp;</td>\n'
    HTMLstring +='<td><b>  A M O U N T </b></td></tr>\n'

    for (i=0;i<nofld;i++) {
       HTMLstring +='<tr>\n'
       d=i+1
       HTMLstring +='<td width="40%">Receipt # ' + d + ' : </td>\n'
       txFldName="txRD" + i
       HTMLstring +='<td width="60%"><input type="text" size="10" name="' + txFldName + '" value="" onKeyDown="if(event.keyCode==13) event.keyCode=9;" onFocusout="UpdateTotal();"></td>\n'
       HTMLstring +='</tr>\n'
    }

    HTMLstring +='<tr>\n'
    HTMLstring +='<td valign="middle"><br><b>Total Amount :</b></td>\n'
    HTMLstring +='<td>--------------------------<br><input type="text" size="15" name="RcptTotal" value="" onKeyDown="if(event.keyCode==13) event.keyCode=9;"><br>--------------------------</td>\n'
    HTMLstring +='</tr>\n'
    HTMLstring +='<tr>\n'
    HTMLstring +='<td colspan="2" align="center"><br>\n'
    HTMLstring +='<input type="button" name="Ddata" value=" Done " onclick="window.opener.' + ow_fld + '.value=document.Rcpts.RcptTotal.value; window.close();">&nbsp;&nbsp;\n'
    HTMLstring +='<input type="Reset" name="clear" value=" Clear ">\n'
    HTMLstring +='</td>\n'
    HTMLstring +='</tr>\n'
    HTMLstring +='</table>\n'
    HTMLstring +='</form>\n'
    HTMLstring +='</p></fieldset>\n'

    HTMLstring +='</BODY>\n'
    HTMLstring +='</HTML>'
    tnw.write(HTMLstring)

    tnw.close()

}

-->

