SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 69 | Next

Richard Wagner

"Professional iPhone and iPod touch Programming: Building Applications for Mobile Safari"

css:
input.calc {
padding: 6px 6px 6px 120px;
}
This class style overrides the default padding to account for the longer labels used in the calculator.
The three input elements have a dummy name attribute that includes zip in it. The zip string
prompts the numeric keyboard to display rather than the alphabet keyboard.
The purpose of the form is for the user to enter information in the first three input elements and
then call the JavaScript function calc() , which then displays the results in the bottom two input
fields. Because the calculation is performed inside of a client - side JavaScript, no submittal is needed
with the server.
The JavaScript function calc() needs to reside in the document head of the main irealtor.html file, not
the document fragment. Here ??™ s the scripting code:
< script type=???application/x-javascript??? >
function calc() {
var amt = document.getElementById(???amt??™).value;
var ir = document.getElementById(???ir??™).value / 1200;
var term = document.getElementById(???term??™).value * 12;
var total=1;
for (i=0;i < term;i++) {
total = total * (1 + ir);
}
var mp = amt * ir / ( 1 - (1/total));
document.getElementById(???payment??™).value = Math.round(mp*100)/100;
document.getElementById(???total??™).


Pages:
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81