Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004

    Unanswered: Setting the value of a textbox


    I want the users to be able to calculate the monthly/weekly repayments based on the amount of the loan.
    When they hit submit, it calls a function & performs the calculations but I'm having trouble assigning the values into the monthly & weekly textboxes then.

    <script language="vbscript">
    function calculate()
    dim time, amt, total, int, intTotal, finalTotal, month, monthly, week, weekly
    time = frmCal.txtDuration.value
    amt = frmCal.txtAmt.value
    int = 0.08
    if CCur(time) = 1 then
    	month = 12
    	week = 52
    ElseIf CCur(time) = 2 then
    	month = 24
    	week = 104
    End If
    intTotal = (CCur(amt) * CCur(int))
    total = (CCur(intTotal) + CCur(amt))
    monthly = (CCur(total) / CCur(month))
    weekly = (CCur(total) / CCur(week))
    Document.Write("Monthly Repayments: " & CCur(monthly) & "<br>")
    Document.Write("Weekly Repayments: " & CCur(weekly))
    end function
    <form name="frmCal" action=# method="POST">
    <table align=center border=1 width="394" rules="none">
    		<th align=center width="194">Duration of Loan in Years</th>
    		<th align=center width="194">Amount to Borrow</th>
    		<td align=center width="194"><input type="text" name="txtDuration" value="" </td>
    		<td align=center width="194"><input type="text" name="txtAmt" value="" </td>
    		<td colspan = "2" align=center width="384"><input type="submit" name="cal" value="Calculate" onClick="calculate()">
    		<th align=center width="194">Monthly Repayments</th>
    		<th align=center width="194">Weekly Repayments</th>
    		<td align=center width="194"><input type="text" name="txtMonthly" value="" </td>
    		<td align=center width="194"><input type="text" name="txtWeekly" value="" </td>
    Can someone tell what to do please...thanks*

  2. #2
    Join Date
    Jun 2003
    With server-side VBScript (i.e. ASP code):

    ASP Design Tips - Post Back Page


    Toward the top of the form (and Request.TotalBytes does NOT include any querystring variables):
    If Request.TotalBytes > 0 Then
    LName = Request.Form("LName")
    FName = Request.Form("FName")
    Address = Request.Form("Address")
    LName = ""
    FName = ""
    Address = ""
    End If

    And here are the form fields themselves:
    <input type="text" name="LName" value="<%= LName %>">
    <input type="text" name="FName" value="<%= FName %>">
    <input type="text" name="Address" value="<%= Address %>">
    J. Paul Schmidt, Freelance Web and Database Developer
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts