The Mortgage Variables Form

[Previous] [Next]

When first running this solution, you will see a form presented in your browser asking you for the assorted loan variables mentioned earlier. The page initially looks like Figure 9-2.

click to view at full size.

Figure 9-2. The mortgage calculation input form.

This form is generated from the ASP script, and certain parts are included only if the browser supports COM controls. Here is the section of the Default.asp page where I generate the form:

  ' ASP code above If m_fUseCSS Then %> <td valign=middle><p  style="font-family:Tahoma;font-size:18pt;font-weight:bold;"> The Mortgage Calculator</p></td> <% Else %> <td valign=middle><p><font face=Tahoma size=5><b> The Mortgage Calculator</b></font></p></td> <% End If %> <td align=right><img src="/books/3/208/1/html/2/PoweredByMSOWC.gif"></td> </tr></table> <form action="Default.asp" method=Get> <p><font face=Verdana size=2> I'm interested in mortgage information for a house that costs $ <input type="text" name="Price" size=8 value=<%= m_nPrice %>> and I am willing to pay <input type="text" name="PctDown" size=2 value=<%= m_nPctDown * 100 %>> % as a down payment. I also want to pay an extra $ <input type="text" name="AddPayment" size=8 value=<%= m_nAddPayment %>> each payment toward reducing the principal.  Assume that I want a <input type="text" name="Years" size=2 value=<%= m_nYears %>> year loan at <input type="text" name="Rate" size=3 value=<%= m_nRate * 100 %>> % interest. <% If m_BrowserInfo.ActiveXControls Then %> <br> <input type="checkbox" name=Interactive id=chkInteractive <% If m_fInteractive Then %>  checked  <% End If %> onclick="chkPayTable.disabled=(chkInteractive.checked);" > <label for=chkInteractive> Return an interactive Spreadsheet control </label> <% End If %> <br> <input type="checkbox" name=PayTable id=chkPayTable <% If m_fPayTable Then %>  checked  <% End If %> <% If m_fInteractive Then %>  disabled <% End If %> > <label for=chkPayTable> Show me a full payment table </label> <p> <input type="submit" value="Calculate My Mortgage!" id=btnSubmit> </font></p> </form>  

At the beginning of this code and HTML segment, I use the m_fUseCSS flag to determine what kind of formatting I should use for the form header. If the flag is True, I can use more precise formatting of the fonts. The main part of the form is a standard HTML form, but it is arranged in a sentence-building manner. Near the end of the form, I use the ActiveXControls property of the BrowserType object to determine whether the client browser supports COM controls. If it does, I emit a check box (the Interactive check box) that the user can check to get the calculation results in an interactive Spreadsheet control instead of static HTML. If not, I don't emit the check box and the user will never know what he or she is missing. (This is why I'm not in marketing.)

Note that I also include a small in-line onClick event handler for the Interactive check box. It makes no sense to exclude the payment table from the Spreadsheet control, so I disable the PayTable check box if the Interactive check box is currently checked.



Programming Microsoft Office 2000 Web Components
Programming Microsoft Office 2000 Web Components (Microsoft Progamming Series)
ISBN: 073560794X
EAN: 2147483647
Year: 1999
Pages: 111
Authors: Dave Stearns

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net