If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Setting the value of a textbox

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-28-04, 06:42
lklegend lklegend is offline
Registered User
 
Join Date: Jan 2004
Posts: 27
Setting the value of a textbox

Hi,

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.

Code:
<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
</script>

<body>
<form name="frmCal" action=# method="POST">
<table align=center border=1 width="394" rules="none">
	<tr>
		<th align=center width="194">Duration of Loan in Years</th>
		<th align=center width="194">Amount to Borrow</th>
	</tr>
	<tr>
		<td align=center width="194"><input type="text" name="txtDuration" value="" </td>
		<td align=center width="194"><input type="text" name="txtAmt" value="" </td>
	</tr>
	<tr>
		<td colspan = "2" align=center width="384"><input type="submit" name="cal" value="Calculate" onClick="calculate()">
	</tr>
	<tr>
		<th align=center width="194">Monthly Repayments</th>
		<th align=center width="194">Weekly Repayments</th>
	</tr>
	<tr>
		<td align=center width="194"><input type="text" name="txtMonthly" value="" </td>
		<td align=center width="194"><input type="text" name="txtWeekly" value="" </td>
	</tr>
</table>
Can someone tell what to do please...thanks*
Reply With Quote
  #2 (permalink)  
Old 03-02-04, 01:50
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
With server-side VBScript (i.e. ASP code):

ASP Design Tips - Post Back Page
http://www.bullschmidt.com/devtip-postbackpage.asp

And:

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")
Else
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
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On