Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
<head>
  <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet"/>
  <link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet"/>

</head>

<body class="container">
  <div class="row">
    <div class="span6">
    <h1 align="center">Mortgage Calculator</h1>
      <form class="form-horizontal well"  name="MortgageMinder" >
        <div class="control-group">
          <label class="control-label">House Price</label>
          <div class="controls">
            <input type="text" onchange="checkForZero(this)" onblur="checkForZero(this)" size="7" value="750000" name="price"></input>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label">Interest Rate</label>
          <div class="controls">
          <input type="text" onchange="checkForZero(this)" onblur="checkForZero(this)" size="4" value="6" name="ir"></input>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label">Years</label>
          <div class="controls">
          <input type="text" onchange="checkForZero(this)" onblur="checkForZero(this)" size="4" value="30" name="term">
          </input>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label">Down Payment</label>
          <div class="controls">
          <input type="text" size="7" onchange="calculatePayment(this.form)" value="0" name="dp">
          
          </input>
          </div>
        </div>
        <br/>
        <div class="control-group">
          <label class="control-label">Mortgage Principle</label>
          <div class="controls">
          <input type="text" size="7" placeholder="Automatically Calculated" name="principle">
          
          </input>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label">Total Payments</label>
          <div class="controls">
          <input type="text" size="6" placeholder="Your Number Of Payments Are" name="payments">
          
          </input>
          </div>
        </div>
        <div class="control-group">
          <label class="control-label">Monthly Payment</label>
          <div class="controls">
          <input type="text" placeholder="Monthly Payments" size="7" name="pmt">
          </input>
          </div>
        </div>
        <div class="control-group">
          <div class="controls">
          <input type="button"  class="btn btn-primary btn-large" onclick="cmdCalc_Click(this.form)" value="Calculate" name="cmdCalc">
          </input>
          </div>
        </div>
      </form>
      <p>Please not that this Mortgage Calculator is only to give you a idea on what loan payments will cost if need to find out current Interest Rate please feel free to contact bank.  </p>
    </div>
 </div>
  </body>
</html>
              
            
!

CSS

              
                body {
  padding: 1%;
}
h2 {
  text-align: center;
}
              
            
!

JS

              
                function checkForZero(field) {
        if (field.value == 0 || field.value.length == 0) {
            alert ("This field can't be 0!");
            field.focus(); }
        else
	    calculatePayment(field.form);
    }

    function cmdCalc_Click(form) {
        if (form.price.value == 0 || form.price.value.length == 0) {
            alert ("The Price field can't be 0!");
            form.price.focus(); }
        else if (form.ir.value == 0 || form.ir.value.length == 0) {
            alert ("The Interest Rate field can't be 0!");
            form.ir.focus(); }
        else if (form.term.value == 0 || form.term.value.length == 0) {
            alert ("The Term field can't be 0!");
            form.term.focus(); }
        else
            calculatePayment(form);
    }

    function calculatePayment(form) {
        princ = form.price.value - form.dp.value;
        intRate = (form.ir.value/100) / 12;
        months = form.term.value * 12;
        form.pmt.value = Math.floor((princ*intRate)/(1-Math.pow(1+intRate,(-1*months)))*100)/100;
  	form.principle.value = princ;
	form.payments.value = months;
    }
              
            
!
999px

Console