School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
You're Browsing As A Guest! Register Now...
Become an Expert!

Join 357,969 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,568 people online right now.Registration is fast and FREE... Join Now!



Help With This Code?

Help With This Code?

#1 devian  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 27-April 03


Dream Kudos: 0

Posted 24 November 2003 - 05:02 AM

I've been working on this code for a few days and I can't seem to figure out what's wrong.

It's supposed to:
1- Have a scrolling msg in a text box using Javascript
2- Give an answer in the form at the bottom

Neither seem to be working.

Can anyone help?

<html>
<head>
<title>Home Finders Nationwide Realty</title>



<script  LANGUAGE="Javascript">
<!-- Hide from old browsers
	var scrollMsg="Mortgage Rates are at their LOWEST!"
	var msgSpace="--- ---"
	var beginPos=0
function scollingMsg() {
document.msgForm.scrollingMsg.value=
scrollMsg.substring(beginPos,scrollMsg.length)+msgSpace+scrollMsg.substring(0,beginPos)
beginPos=beginPos+1
if (beginPos>scrollMsg.length) {
beginPos=0
}
window.setTimeout("scrollingMsg()",200)
}

function doMort() {
document.MortCalc.Amount.value=""
document.MortCalc.Rate.value=""
document.MortCalc.Years.value=""
document.MortCalc.Payment.value=""
document.MortCalc.Amount.focus()
}
function Calc(myfrm) {
var mortAmount=document.MortCalc.Amount.value
var mortAmount=parseInt(mortAmount, 10)
if (isNaN(mortAmount)) {
alert("The Interest rate is not a number!")
document.MortCalc.Rate.value=""
document.MortCalc.Rate.focus()
}
else
{
var mortYears=document.MortCalc.Years.value
var mostYears=parseInt(mortYears,10)
is (isNaN(mostYears)) {
alert("The Interest rate is not a number!")
document.MortCalc.Years.value=""
document.MostCalc.Years.focus()
}}}
document.MortCalc.Payment.value=monthly(mortAmount,mortRate,mortYears)
document.MortCalc.Payment.value=dollarFormat(document.MortCalc.Payment.value)
}
function monthly(mortAmount,mortRate,mortYears) {
var Irate=mortrate/1200
var Pmts=mortYears*12
var Loan=mortAmount
return Loan*(Irate/(1-(1/Math.pow(1+Irate,PMTS))))
}
function dollarFormat(valuein)
{
var formatStr=""
var Outdollars=""
var decipos=valuein.indexOf(".")
if (decipos==-1)
decipos=valuein.length
var dollars=valuein.substring(0,decipos)
var dollen=dollars.length
if (dollen>3)
{
while (dollen>o)
{
tDollars=dollars.substring(dollen-3,dollen)
if (tDollars.length==3)
{
Outdollars=","+tDollars+Outdollars
dollen=dollen-3
} else {
Outdollars=tdollars+Outdollars
dollen=0
}}
if (Outdollars.substring(0,1)==",")
dollars=Outdollars.substring(1,Outdollars.length)
else
dollars=Outdollars
}
var cents=valuein.substring(decipos+1,decipos+3)
if (cents=="")
cents="00"
var formatStr+"$"+dollars+"."+cents
return formatStr
}
//-->
</script>
</head>

<body onload="scrollingMsg()">




<p align="center"><img src="homelogo.jpg">
</p>
<div align="center"><center>
<table border="0" width="75%">
<tr>
<td></td>
<td><p align="center"><img src="calc.gif" width="100" height="106">
</a></td>
<td></td>
</tr>
<tr>
<td><p align="center"><img src="house1.gif" width="180" Height="144"></td>
<td><p align="center">
<a href="#LoanCalc">Estimate Monthly Payment</a>
</p>
<form name="msgForm">
<input type="text" name="scrollingMsg" size="23">
</form>
</td>
<td><p align="center"><img src="house2.gif" width="180" height="144"></td>
</tr>
<tr>
<td></td>
<td><img src="house3.gif" width="180" height="144"></td>
<td></td>
</tr>
</table>
</center></div>
<p align="center">
<br>
<a name="LoanCalc"></p>
<h3 align="center">Estimate Mortgage Payments</h3>
</a>
<center>
<form name="MortCalc"><table>
<tr>
<td>Amount of Mortgage:</td>
<td><Input type="text" name="amount" value="" size="9"></td>
</tr>
<tr>
<td>Interest Rate as % (e.g. 7.9):</td>
<td><input type="text" name="Rate" value="" size"9"></td>
</tr>
<tr>
<td>Number of years:</td>
<td><input type="text" name="Years" value="" size="9"></td>
</tr>
<tr>
<td>Monthly Payment:</td>
<td><INPUT type="text" Name="Payment" value="" size="12"></td>
</tr>
<tr>
<td><INPUT type="button" value="Calculate">
<INPUT Type="Reset"></td>
</tr>
</table>
</form>
</center>
<hr>
<br>
<br>
</body>
</html> 


Was This Post Helpful? 0
  • +
  • -


#2 Jayen  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 04-May 04


Dream Kudos: 0

Re: Help With This Code?

Posted 04 May 2004 - 09:31 PM

If you are still working on this, I have a couple of samples under the Scripts portion at this URL. One does your scrolling trick, another does Mortgage calculations:

http://netdotwww.com/workshop

I must point out this is pretty dated stuff but has plenty of basics included.
Was This Post Helpful? 0
  • +
  • -

#3 MstigidC  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 11-May 04


Dream Kudos: 0

Re: Help With This Code?

Posted 12 May 2004 - 10:11 AM

not quite sure if this is what u were looking for, but this is a scrollingmessage and it is very easy to understand.

Quote

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script language="Javascript1.2"><!--
var sp=0;
function swtScroll() {
scrtext=document.getElementById?document.getElementById("sctext"):document.all["sctext"];
maxp=scrtext.offsetHeight?scrtext.offsetHeight:scrtext.style.pixelHeight;
if (sp<-maxp) sp=0;
sp--;
scrtext.style.top=sp;
setTimeout('swtScroll()',100); // larger number = slower scroll
}
if (!document.layers) window.onload=swtScroll;
//--></script>

</head>

<body>

<div style="overflow:hidden;width:600px;height:50px;padding:10px;">
<div id="sctext" style="position:relative;font-size:100%;">
<b>this is a random test of a scrolling box that was done for no reason at all except for just to see what would happen.  this is a random test of a scrolling box that was done for no reason at all except for just to see what would happen.
this is a random test of a scrolling box that was done for no reason at all except for just to see what would happen.</b>
</div></div>

</body>
</html>

Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month