...

View Full Version : Rent Proration Calculator



nikschultz
03-11-2005, 04:09 AM
I have been looking online for something I can use to calculate:

Base Rent + Pet Rent + Parking Rent+Tax=Total Monthly Rent

I would like the tax to be automatically calculated and shown so we can print the page and see all of the values.

Along with this I am trying to have it calculate the amount it costs per day for that specific month they move in (28/30/31 days) and also the total amount for the number of days they will be there for that month, all by entering their move in date.

I am looking for pretty much anything from html and java and either excel or word documents.

Any help would be great!

Thanks
Nik :confused:

Maybe something similar to this... Not completely the same can be different.
http://www.geocities.com/nikschultz/Untitled.html

moke
03-12-2005, 04:10 AM
All I know is c and I am not even sure how to run it on anything except unix. I will gladly set up a template in Word that will allow you to just put in what day it is and make a couple of simple alterations and print it out. I would need you to give the monthly amount of rent all the figures you mentioned. It will be for a 30 day period. Which I will tell you is a very common method because it all averages out to be 30 days. I can't gurantee but I will try to set it up. Just e-mail me with the SUBJECT of RENT formula and I will get to work.

jalarie
03-14-2005, 05:39 PM
Between scrip tags within your body, try this:

BaseRent=400; // per-month
PetRent = 50;
Parking = 10;
TaxRate = 6; // percent

document.write(' <br \/>\n');
document.write(' <center>\n');
document.write(' <form method="post" target="_blank" action="" onsubmit="return CheckIt()">\n');
document.write(' <table border="0" cellspacing="0" cellpadding="2">\n');
document.write(' <tbody>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ffffcc">\n');
document.write(' <input type="checkbox" name="cbr" id="cbr" checked="checked" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">Base Rent&nbsp;&nbsp;&nbsp;&nbsp;<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="right">\n');
document.write(' '+BaseRent+'\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="baserent" id="baserent" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ffffcc">\n');
document.write(' <input type="checkbox" name="cpr" id="cpr" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">Pet Rent<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="right">\n');
document.write(' '+PetRent+'\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="petrent" id="petrent" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ffffcc">\n');
document.write(' <input type="checkbox" name="cp" id="cp" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">Parking<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="right">\n');
document.write(' '+Parking+'\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="parking" id="parking" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ffffcc">&nbsp;&nbsp;<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">Tax Rate<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="right">\n');
document.write(' '+TaxRate+'%\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="tax" id="tax" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ccffcc" align="left" colspan="3">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' Total\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ccffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="total" id="total" onfocus="this.select();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <\/tbody>\n');
document.write(' <\/table>\n');
document.write(' <\/form>\n');
document.write(' <\/center>\n');


function Calc() {
f1=document.forms[0]; // abbreviation
if (f1.cbr.checked) {
f1.baserent.value=BaseRent;
} else {
f1.baserent.value=0;
}
if (f1.cpr.checked) {
f1.petrent.value=PetRent;
} else {
f1.petrent.value=0;
}
if (f1.cp.checked) {
f1.parking.value=Parking;
} else {
f1.parking.value=0;
}
SubTotal=f1.baserent.value*1 + f1.petrent.value*1 + f1.parking.value*1;
f1.tax.value=SubTotal*TaxRate/100;
Total=SubTotal*1+f1.tax.value*1;
f1.total.value=Total;
return false;
}

nikschultz
03-14-2005, 10:45 PM
Between scrip tags within your body, try this:


Thanks so much for your help, but I am not sure where this is to go. I know a little about html script, but not a lot. I know how to make changes to things that are done and I can figure it out.

Any help is great!

:thumbsup:

jalarie
03-15-2005, 01:30 PM
This includes the move-in date:

BaseRent=400; // per-month
PetRent = 50;
Parking = 10;
TaxRate = 6; // percent

document.write(' <br \/>\n');
document.write(' <center>\n');
document.write(' <form method="post" target="_blank" action="" onsubmit="return CheckIt()">\n');
document.write(' <table border="1" cellspacing="2" cellpadding="2">\n');
document.write(' <tbody>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ccffcc" align="center" colspan="5">\n');
document.write(' Move-in Date\n');
document.write(' <input type="text" name="movein" id="movein" onfocus="this.select();" \/>\n');
document.write(' as MM-DD-YYYY\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <th bgcolor="#ffffcc">Include<\/th>\n');
document.write(' <th bgcolor="#ffffcc">Description<\/th>\n');
document.write(' <th bgcolor="#ffffcc">Full Month<\/th>\n');
document.write(' <th bgcolor="#ffffcc">Part Month<\/th>\n');
document.write(' <th bgcolor="#ffffcc">Per Day<\/th>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="aqua" align="center">\n');
document.write(' <input type="checkbox" name="cbr" id="cbr" checked="checked" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="aqua" align="left">Base Rent&nbsp;&nbsp;&nbsp;&nbsp;<\/td>\n');
document.write(' <td bgcolor="aqua" align="right">\n');
document.write(' '+BaseRent+'\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="aqua" align="center">\n');
document.write(' <input type="text" name="baserent" id="baserent" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="aqua" align="center">\n');
document.write(' <input type="text" name="dayrent" id="dayrent" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="aqua" align="center">\n');
document.write(' <input type="checkbox" name="cpr" id="cpr" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="aqua" align="left">Pet Rent<\/td>\n');
document.write(' <td bgcolor="aqua" align="right">\n');
document.write(' '+PetRent+'\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="aqua" align="center">\n');
document.write(' <input type="text" name="petrent" id="petrent" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="aqua" align="center">\n');
document.write(' <input type="text" name="daypet" id="daypet" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="aqua" align="center">\n');
document.write(' <input type="checkbox" name="cp" id="cp" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="aqua" align="left">Parking<\/td>\n');
document.write(' <td bgcolor="aqua" align="right">\n');
document.write(' '+Parking+'\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="aqua" align="center">\n');
document.write(' <input type="text" name="parking" id="parking" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="aqua" align="center">\n');
document.write(' <input type="text" name="daypark" id="daypark" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="aqua">&nbsp;&nbsp;<\/td>\n');
document.write(' <td bgcolor="aqua" align="left">Tax Rate<\/td>\n');
document.write(' <td bgcolor="aqua" align="right">\n');
document.write(' '+TaxRate+'%\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="aqua" align="center">\n');
document.write(' <input type="text" name="tax" id="tax" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="aqua" align="center">\n');
document.write(' <input type="text" name="daytax" id="daytax" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ccffcc" align="left" colspan="3">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' Total\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ccffcc" align="center">\n');
document.write(' <input type="text" name="total" id="total" onfocus="this.select();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="aqua" align="center">\n');
document.write(' <input type="text" name="daytotal" id="daytotal" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <\/tbody>\n');
document.write(' <\/table>\n');
document.write(' <\/form>\n');
document.write(' <\/center>\n');


function Calc() {
f1=document.forms[0]; // abbreviation
DaysPerMonth=new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
MoveIn=f1.movein.value;
MI_month=MoveIn.substring(0,2) -1; // Jan-Dec = 0-11
MI_day =MoveIn.substring(3,5);
MI_year =MoveIn.substring(6,10);
if (MI_year%4 == 0) { // leap year
DaysPerMonth[1]=29;
}
Days=DaysPerMonth[MI_month]*1 - MI_day*1 + 1;
MonthFraction=Days / DaysPerMonth[MI_month];
if (f1.cbr.checked) {
f1.baserent.value=BaseRent*MonthFraction;
} else {
f1.baserent.value=0;
}
if (f1.cpr.checked) {
f1.petrent.value=PetRent*MonthFraction;
} else {
f1.petrent.value=0;
}
if (f1.cp.checked) {
f1.parking.value=Parking*MonthFraction;
} else {
f1.parking.value=0;
}
f1.dayrent.value=f1.baserent.value/Days;
f1.daypet.value =f1.petrent.value /Days;
f1.daypark.value=f1.parking.value /Days;
f1.daytax.value =f1.tax.value /Days;

f1.dayrent.value=Math.floor(f1.dayrent.value*100)/100;
f1.daypet.value =Math.floor(f1.daypet.value*100)/100;
f1.daypark.value=Math.floor(f1.daypark.value*100)/100;
f1.daytax.value =Math.floor(f1.daytax.value*100)/100;

SubTotal=f1.baserent.value*1 + f1.petrent.value*1 + f1.parking.value*1;
f1.tax.value=SubTotal*TaxRate/100;
Total=SubTotal*1+f1.tax.value*1;
f1.total.value=Total;
f1.daytotal.value=Total/Days;
f1.daytotal.value=Math.floor(f1.daytotal.value*100)/100;
return false;
}

jimmy409
12-09-2011, 07:24 AM
Hello,

I am trying to get the code posted by 'jalarie' on 03-15-2005 06:30AM to work.

Have tried to post the code into 'Office Frontpage' between the tags: <script type="text/javascript"> & </script>

Nothing shows up when I open the created HTML page. What am I doing wrong?

Then, I tried to test the code here:

http://writecodeonline.com/javascript/

The code does not calculate the totals.

I am familiar with basic HTML, would someone please help me get this code working?

Thank you.

Jimmy

Philip M
12-09-2011, 08:18 AM
Hello,

I am trying to get the code posted by 'jalarie' on 03-15-2005 06:30AM to work.

Have tried to post the code into 'Office Frontpage' between the tags: <script type="text/javascript"> & </script>

Nothing shows up when I open the created HTML page. What am I doing wrong?

Then, I tried to test the code here:

http://writecodeonline.com/javascript/

The code does not calculate the totals.

I am familiar with basic HTML, would someone please help me get this code working?

Thank you.

Jimmy

Have you tried contacting jalerie? He is an active contributor to this forum.

You tested the code and you say it worked (but did not calculate totals) so there must be an error in how you copied the code into Frontpage (Ugh!!). It would be better to place it in an external .js file.

The calculations will only take place when you call the function Calc().

<script type = "text/javascript">
Calc();
</script>

"The best horse won, and that's all you can ask in any sport". - Racing commentator

jalarie
12-09-2011, 07:50 PM
Have you tried contacting jalerie? He is an active contributor to this forum.

I'm still here and paying attention, just not on when this discussion started.


The calculations will only take place when you call the function Calc().


<script type = "text/javascript">
Calc();
</script>


Not true. The total should calculate and display whenever you tab out of one of the check-box fields.

I just did a copy-paste of the (rather old and not the way I'd do it today) posted code into a simple web page (NOT Frontpage UGH!) and it works fine.

Please let me know if there's something I can do to help.

jimmy409
12-09-2011, 11:16 PM
I'm still here and paying attention, just not on when this discussion started.

Not true. The total should calculate and display whenever you tab out of one of the check-box fields.

I just did a copy-paste of the (rather old and not the way I'd do it today) posted code into a simple web page (NOT Frontpage UGH!) and it works fine.

Please let me know if there's something I can do to help.

Hello,

Thank you for your input.

I still cannot get it to work. Tried Webplus... Frontpage... Would you please tell me which web page program you used to input the code into?

Thank you so much!

jimmy

jalarie
12-09-2011, 11:34 PM
Hello,

Thank you for your input.

I still cannot get it to work. Tried Webplus... Frontpage... Would you please tell me which web page program you used to input the code into?

Thank you so much!

jimmy

I don't use any of those; I write it myself. This is the code I ran:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>Test Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Language" content="en-US" />
<meta name="Author" content="James Alarie - jalarie@umich.edu" />
<meta name="description" content="Test a form for Coding Forums." />
<meta name="keywords" content="test,form,coding,forums" />
<link rev="made" href="mailto:jalarie@umich.edu" />
<!--
Author: James Alarie
Company: -independent-
Address: 3391 N Genesee Rd
Flint MI 48506
Latitude: 42.9663 Longitude: -83.7769
Telephone: +1-810-736-8259
Fax: -none-
Web Site: http://spruce.flint.umich.edu/~jalarie/
E-Mail: jalarie@umich.edu
Comments: Having said that, I've probably told you more than I know.
-->
</head>
<body class="body1">
<div id="body">
<!-- Page Header -->
<div id="header">
<h1>Test Form</h1>
<hr />
</div>
<!-- Content -->
<div id="content">
<br />
<noscript>
<p class="notice">
You must have scripting enabled to make full use of this page.
</p>
</noscript>
<script type="text/javascript">
/*<![CDATA[*/

BaseRent=400; // per-month
PetRent = 50;
Parking = 10;
TaxRate = 6; // percent

document.write(' <br \/>\n');
document.write(' <center>\n');
document.write(' <form method="post" target="_blank" action="" onsubmit="return CheckIt()">\n');
document.write(' <table border="0" cellspacing="0" cellpadding="2">\n');
document.write(' <tbody>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ffffcc">\n');
document.write(' <input type="checkbox" name="cbr" id="cbr" checked="checked" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">Base Rent&nbsp;&nbsp;&nbsp;&nbsp;<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="right">\n');
document.write(' '+BaseRent+'\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="baserent" id="baserent" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ffffcc">\n');
document.write(' <input type="checkbox" name="cpr" id="cpr" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">Pet Rent<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="right">\n');
document.write(' '+PetRent+'\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="petrent" id="petrent" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ffffcc">\n');
document.write(' <input type="checkbox" name="cp" id="cp" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">Parking<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="right">\n');
document.write(' '+Parking+'\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="parking" id="parking" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ffffcc">&nbsp;&nbsp;<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">Tax Rate<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="right">\n');
document.write(' '+TaxRate+'%\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="tax" id="tax" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ccffcc" align="left" colspan="3">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' Total\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ccffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="total" id="total" onfocus="this.select();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <\/tbody>\n');
document.write(' <\/table>\n');
document.write(' <\/form>\n');
document.write(' <\/center>\n');


function Calc() {
f1=document.forms[0]; // abbreviation
if (f1.cbr.checked) {
f1.baserent.value=BaseRent;
} else {
f1.baserent.value=0;
}
if (f1.cpr.checked) {
f1.petrent.value=PetRent;
} else {
f1.petrent.value=0;
}
if (f1.cp.checked) {
f1.parking.value=Parking;
} else {
f1.parking.value=0;
}
SubTotal=f1.baserent.value*1 + f1.petrent.value*1 + f1.parking.value*1;
f1.tax.value=SubTotal*TaxRate/100;
Total=SubTotal*1+f1.tax.value*1;
f1.total.value=Total;
return false;
}

/*]]>*/
</script>
</div>
<!-- Page Footer -->
<div id="footer">
<br clear="all" /><hr />
Written on December 9, 2011, by:&nbsp;
<a href="mailto:jalarie@umich.edu">James Alarie</a>.
</div>
</div>
</body>
</html>

jimmy409
03-10-2012, 11:08 AM
I don't use any of those; I write it myself. This is the code I ran:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>Test Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Language" content="en-US" />
<meta name="Author" content="James Alarie - jalarie@umich.edu" />
<meta name="description" content="Test a form for Coding Forums." />
<meta name="keywords" content="test,form,coding,forums" />
<link rev="made" href="mailto:jalarie@umich.edu" />
<!--
Author: James Alarie
Company: -independent-
Address: 3391 N Genesee Rd
Flint MI 48506
Latitude: 42.9663 Longitude: -83.7769
Telephone: +1-810-736-8259
Fax: -none-
Web Site: http://spruce.flint.umich.edu/~jalarie/
E-Mail: jalarie@umich.edu
Comments: Having said that, I've probably told you more than I know.
-->
</head>
<body class="body1">
<div id="body">
<!-- Page Header -->
<div id="header">
<h1>Test Form</h1>
<hr />
</div>
<!-- Content -->
<div id="content">
<br />
<noscript>
<p class="notice">
You must have scripting enabled to make full use of this page.
</p>
</noscript>
<script type="text/javascript">
/*<![CDATA[*/

BaseRent=400; // per-month
PetRent = 50;
Parking = 10;
TaxRate = 6; // percent

document.write(' <br \/>\n');
document.write(' <center>\n');
document.write(' <form method="post" target="_blank" action="" onsubmit="return CheckIt()">\n');
document.write(' <table border="0" cellspacing="0" cellpadding="2">\n');
document.write(' <tbody>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ffffcc">\n');
document.write(' <input type="checkbox" name="cbr" id="cbr" checked="checked" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">Base Rent&nbsp;&nbsp;&nbsp;&nbsp;<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="right">\n');
document.write(' '+BaseRent+'\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="baserent" id="baserent" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ffffcc">\n');
document.write(' <input type="checkbox" name="cpr" id="cpr" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">Pet Rent<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="right">\n');
document.write(' '+PetRent+'\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="petrent" id="petrent" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ffffcc">\n');
document.write(' <input type="checkbox" name="cp" id="cp" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">Parking<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="right">\n');
document.write(' '+Parking+'\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="parking" id="parking" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ffffcc">&nbsp;&nbsp;<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">Tax Rate<\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="right">\n');
document.write(' '+TaxRate+'%\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ffffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="tax" id="tax" onfocus="this.select();" onblur="Calc();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <tr>\n');
document.write(' <td bgcolor="#ccffcc" align="left" colspan="3">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' Total\n');
document.write(' <\/td>\n');
document.write(' <td bgcolor="#ccffcc" align="left">\n');
document.write(' &nbsp;&nbsp;&nbsp;&nbsp;\n');
document.write(' <input type="text" name="total" id="total" onfocus="this.select();" \/>\n');
document.write(' <\/td>\n');
document.write(' <\/tr>\n');
document.write(' <\/tbody>\n');
document.write(' <\/table>\n');
document.write(' <\/form>\n');
document.write(' <\/center>\n');


function Calc() {
f1=document.forms[0]; // abbreviation
if (f1.cbr.checked) {
f1.baserent.value=BaseRent;
} else {
f1.baserent.value=0;
}
if (f1.cpr.checked) {
f1.petrent.value=PetRent;
} else {
f1.petrent.value=0;
}
if (f1.cp.checked) {
f1.parking.value=Parking;
} else {
f1.parking.value=0;
}
SubTotal=f1.baserent.value*1 + f1.petrent.value*1 + f1.parking.value*1;
f1.tax.value=SubTotal*TaxRate/100;
Total=SubTotal*1+f1.tax.value*1;
f1.total.value=Total;
return false;
}

/*]]>*/
</script>
</div>
<!-- Page Footer -->
<div id="footer">
<br clear="all" /><hr />
Written on December 9, 2011, by:&nbsp;
<a href="mailto:jalarie@umich.edu">James Alarie</a>.
</div>
</div>
</body>
</html>


Hello,

I still do not understand.

Where did you paste the code in a webpage? Or what program did you paste the code into?

Thank you again.

jimmy

jalarie
03-10-2012, 04:08 PM
Hello, I still do not understand. Where did you paste the code in a webpage? Or what program did you paste the code into?
Thank you again. jimmy

"Where in a webpage" and "what program": Nowhere; none.

Forget about "in" any existing web page, and forget about using any program that creates web pages. Use Notepad to copy-and-paste my posted code into a *new* file with the .htm suffix, and then open that file with your favorite browser. It should basically work as-is. Then tweek it to get it to work exactly the way you want it.

I'll repeat a previous comment: That is the way I did it back at the time of the original posting; it's NOT how I would do it today.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum