   [web] My javascript code!
  I am trying to script some calculations, but I am afraid I am not an expert with &#106avascript. Can anyone tell me why my code seems to be getting stuck in the second function I call?<head><title>How Much House Can My Borrower Afford?</title><script type = "text/javascript">function main(form){var total1;var total2;var total3;var total4;var gmi;var mo;var con1;var con2;var tmda;var piti1;var piti2;var lpiti;var factor;var emla;var ltv;var empp;gmi_b();alert(total1);gmi_c();mo_b();mo_c();/*var total1;var total2;var total3;var total4;var gmi = total1+total2;var mo = total3+total4;var con1;var con2;var tmda = gmi*con1;var piti1 = tmda-mo;var piti2 = gmi*con2;var lpiti = Math.min(piti1,piti2);var factor;var emla = lpiti*factor;var ltv = eval(form.ltv.value)/[100];var empp = emla/ltv;*/}function gmi_b(form){if(a1 != "" || b1 != "" || c1 != "" || d1 != "" || e1 != ""){var a1 = eval(form.txt1.value);   var b1 = eval(form.txt2.value);var c1 = eval(form.txt3.value);var d1 = eval(form.txt4.value);var e1 = eval(form.txt5.value);var total1 = a1+b1+c1+d1+e1;total1 = total1 * [100];total1 = Math.round(total1)total1 /= [100];} }function gmi_c(form){if(a2 != "" || b2 != "" || c2 != "" || d2 != "" || e2 != ""){var a2 = eval(form.txt11.value);var b2 = eval(form.txt22.value);var c2 = eval(form.txt33.value);var d2 = eval(form.txt44.value);var e2 = eval(form.txt55.value);var total2 = a2+b2+c2+d2+e2;total2 = total2 * [100];total2 = Math.round(total2)total2 /= [100];} }function mo_b(form){if(a3 != "" || b3 != "" || c3 != "" || d3 != ""){var a3 = eval(form.txt111.value);var b3 = eval(form.txt222.value);var c3 = eval(form.txt333.value);var d3 = eval(form.txt444.value);var total3 = a3+b3+c3+d3;total3 = total3 * [100];total3 = Math.round(total3)total3 /= [100];} }function mo_c(form){if(a4 != "" || b4 != "" || c4 != "" || d4 != ""){var a4 = eval(form.txt1111.value);var b4 = eval(form.txt2222.value);var c4 = eval(form.txt3333.value);var d4 = eval(form.txt4444.value);var total4 = a4+b4+c4+d4;total4 = total4 * [100];total4 = Math.round(total4)total4 /= [100];} }</script></head><body><big><big><u><b>How Much House Can My Borrower Afford?</b></u></big></big><br><form id = "ltv1"><table border="[1]" cellpadding=[5]><tr><td align=center><b>LTV:</b></td><td align=center>$<input type = text size = [2] name = ltv value = [0] onFocus="select()">%</td></tr></table></form><form id = "aa"><table border="[1]" cellpadding=[5]><tr><td align=center><select><option value ="[15]" selected="selected">[15]</option><option value ="[30]">[30]</option></select>Year Loan</td><td align=center><select><option value ="[5].[0]" selected="selected">[5].[0]</option><option value ="[5].[5]">[5].[5]</option><option value ="[6].[0]">[6].[0]</option><option value ="[6].[5]">[6].[5]</option><option value ="[7].[0]">[7].[0]</option><option value ="[7].[5]">[7].[5]</option><option value ="[8].[0]">[8].[0]</option><option value ="[8].[5]">[8].[5]</option><option value ="[9].[0]">[9].[0]</option><option value ="[9].[5]">[9].[5]</option><option value ="[10].[0]">[10].[0]</option><option value ="[10].[5]">[10].[5]</option></select>%Rate</td></tr></table></form><big><b>Gross Monthly Income</b></big><form id = "a"><table border="[1]" cellpadding=[5]><td align=center><b><u>For Borrower</u></b></td><tr><td align=center>Base Employment Income:</td><td align=center>$<input type = text name = txt1 value = [0] onFocus="select()"></td></tr><tr><td align=center>Overtime:</td><td align=center>$<input type = text name = txt2 value = [0] onFocus="select()"></td></tr><tr><td align=center>Part-Time:</td><td align=center>$<input type = text name = txt3 value = [0] onFocus="select()"></td></tr><tr><td align=center>Commissions:</td><td align=center>$<input type = text name = txt4 value = [0] onFocus="select()"></td></tr><tr><td align=center>Other:</td><td align=center>$<input type = text name = txt5 value = [0] onFocus="select()"></td></tr></table></form><form id = "b"><table border="[1]" cellpadding=[5]><td align=center><b><u>For Co-Borrower</u></b></td><tr><td align=center>Base Employment Income:</td><td align=center>$<input type = text name = txt11 value = [0] onFocus="select()"></td></tr><tr><td align=center>Overtime:</td><td align=center>$<input type = text name = txt22 value = [0] onFocus="select()"></td></tr><tr><td align=center>Part-Time:</td><td align=center>$<input type = text name = txt33 value = [0] onFocus="select()"></td></tr><tr><td align=center>Commissions:</td><td align=center>$<input type = text name = txt44 value = [0] onFocus="select()"></td></tr><tr><td align=center>Other:</td><td align=center>$<input type = text name = txt55 value = [0] onFocus="select()"></td></tr></table></form><big><b>Monthly Obligations</b></big><form id = "c"><table border="[1]" cellpadding=[5]><td align=center><b><u>For Borrower</u></b></td><tr><td align=center>Auto Loans:</td><td align=center>$<input type = text name = txt111 value = [0] onFocus="select()"></td></tr><tr><td align=center>Installment Loans:</td><td align=center>$<input type = text name = txt222 value = [0] onFocus="select()"></td></tr><tr><td align=center>Credit Cards:</td><td align=center>$<input type = text name = txt333 value = [0] onFocus="select()"></td></tr><tr><td align=center>Other:</td><td align=center>$<input type = text name = txt444 value = [0] onFocus="select()"></td></tr></table></form><form id = "d"><table border="[1]" cellpadding=[5]><td align=center><b><u>For Co-Borrower</u></b></td><tr><td align=center>Auto Loans:</td><td align=center>$<input type = text name = txt1111 value = [0] onFocus="select()"></td></tr><tr><td align=center>Installment Loans:</td><td align=center>$<input type = text name = txt2222 value = [0] onFocus="select()"></td></tr><tr><td align=center>Credit Cards:</td><td align=center>$<input type = text name = txt3333 value = [0] onFocus="select()"></td></tr><tr><td align=center>Other:</td><td align=center>$<input type = text name = txt4444 value = [0] onFocus="select()"></td></tr></table></form><input type="button" value="  CALCULATE FORM  " onClick="main(this.form)"></body>
  Please:1. Put your code somewhere where it won't be mangled by the gamedev.net auto-code-mucker-upper(1)2. Be much more specific about how it doesn't work. "Code seems to be getting stuck in the second function you call" is way too vague:- Which function- In what way is it "getting stuck"?- What browser are you using?- Have you tried turning relevant &#106avascript debugging options and looking at the output?Mark(1) Trademark 2005 gamedev.net all rights reserved.   ;  Also, you arent passing parameters to your functions (with the exception of main()) and you arent returning values from your functions.   ;  On a side node you should really use better naming standards. Function names like gmi_b(form), gmi_c(form), mo_b(form), and mo_c(form) are just horrible to figure out there purpose.   ;  Oh, sorry about the naming of the functions. They made since to me because of the program I was writing(mo_b = mothly obligations borrower and mo_c = monthly obligations co-borrower). I am also sorry about not being specific, but I fixed the code. Here is the working version if anyone wants to save it and figure house how expensive of a house you can afford without having to fill out an app with a broker.<head><title>How Much House Can My Borrower Afford?</title><script type = "text/javascript">var total1;var total2;var total3;var total4;var gmi;var mo;var con1;var con2;var tmda;var piti1;var piti2;var lpiti;var factor;var emla;var ltv;var empp;function main(form){if(a1 != "" || b1 != "" || c1 != "" || d1 != "" || e1 != ""){var a1 = eval(document.getElementById("txt1").value);   var b1 = eval(document.getElementById("txt2").value);var c1 = eval(document.getElementById("txt3").value);var d1 = eval(document.getElementById("txt4").value);var e1 = eval(document.getElementById("txt5").value);total1 = a1+b1+c1+d1+e1;total1 = total1 * [100];total1 = Math.round(total1);total1 /= [100];}if(a2 != "" || b2 != "" || c2 != "" || d2 != "" || e2 != ""){var a2 = eval(document.getElementById("txt11").value);var b2 = eval(document.getElementById("txt22").value);var c2 = eval(document.getElementById("txt33").value);var d2 = eval(document.getElementById("txt44").value);var e2 = eval(document.getElementById("txt55").value);var total2 = a2+b2+c2+d2+e2;total2 = total2 * [100];total2 = Math.round(total2)total2 /= [100];} if(a3 != "" || b3 != "" || c3 != "" || d3 != ""){var a3 = eval(document.getElementById("txt111").value);var b3 = eval(document.getElementById("txt222").value);var c3 = eval(document.getElementById("txt333").value);var d3 = eval(document.getElementById("txt444").value);var total3 = a3+b3+c3+d3;total3 = total3 * [100];total3 = Math.round(total3)total3 /= [100];} if(a4 != "" || b4 != "" || c4 != "" || d4 != ""){var a4 = eval(document.getElementById("txt1111").value);var b4 = eval(document.getElementById("txt2222").value);var c4 = eval(document.getElementById("txt3333").value);var d4 = eval(document.getElementById("txt4444").value);var total4 = a4+b4+c4+d4;total4 = total4 * [100];total4 = Math.round(total4)total4 /= [100];} var gmi = total1+total2;var mo = total3+total4;if(document.getElementById("ltv").value < [95]){con1 = .[38];con2 = .[33];}else if(document.getElementById("ltv").value >= [95]){con1 = .[36];con2 = .[28];}var tmda = gmi*con1;var piti1 = tmda-mo;var piti2 = gmi*con2;var lpiti = Math.min(piti1,piti2);var y1 = document.getElementById("yy").value;var y2 = document.getElementById("yyy").value;var p5 = document.getElementById("ff1").value;var p55 = document.getElementById("ff2").value;var p6 = document.getElementById("ss1").value;var p65 = document.getElementById("ss2").value;var p7 = document.getElementById("sss1").value;var p75 = document.getElementById("sss2").value;var p8 = document.getElementById("ee1").value;var p85 = document.getElementById("ee2").value;var p9 = document.getElementById("nn1").value;var p95 = document.getElementById("nn2").value;var p10 = document.getElementById("tt1").value;var p105 = document.getElementById("tt2").value;var selc1 = document.getElementById("sel1").value;var selc2 = document.getElementById("sel2").value;if(selc1 == "[15]" && selc2 == "[5].[0]") factor = [101];if(selc1 == "[15]" && selc2 == "[5].[5]") factor = [98];if(selc1 == "[15]" && selc2 == "[6].[0]") factor = [96];if(selc1 == "[15]" && selc2 == "[6].[5]") factor = [93];if(selc1 == "[15]" && selc2 == "[7].[0]") factor = [91];if(selc1 == "[15]" && selc2 == "[7].[5]") factor = [89];if(selc1 == "[15]" && selc2 == "[8].[0]") factor = [87];if(selc1 == "[15]" && selc2 == "[8].[5]") factor = [85];if(selc1 == "[15]" && selc2 == "[9].[0]") factor = [82];if(selc1 == "[15]" && selc2 == "[9].[5]") factor = [80];if(selc1 == "[15]" && selc2 == "[10].[0]") factor = [79];if(selc1 == "[15]" && selc2 == "[10].[5]") factor = [77];if(selc1 == "[30]" && selc2 == "[5].[0]") factor = [134];if(selc1 == "[30]" && selc2 == "[5].[5]") factor = [129];if(selc1 == "[30]" && selc2 == "[6].[0]") factor = [124];if(selc1 == "[30]" && selc2 == "[6].[5]") factor = [119];if(selc1 == "[30]" && selc2 == "[7].[0]") factor = [115];if(selc1 == "[30]" && selc2 == "[7].[5]") factor = [110];if(selc1 == "[30]" && selc2 == "[8].[0]") factor = [106];if(selc1 == "[30]" && selc2 == "[8].[5]") factor = [102];if(selc1 == "[30]" && selc2 == "[9].[0]") factor = [99];if(selc1 == "[30]" && selc2 == "[9].[5]") factor = [95];if(selc1 == "[30]" && selc2 == "[10].[0]") factor = [92];if(selc1 == "[30]" && selc2 == "[10].[5]") factor = [89];var emla = lpiti*factor;emla = emla/[50];emla = Math.floor(emla);emla = emla*[50];var ltv = eval(document.getElementById("ltv").value)/[100];var empp = (emla)/ltv;empp = empp * [100];empp = Math.round(empp);empp = empp / [100];document.getElementById("fin").value = empp;if(document.getElementById("fin").value == "Infinity") document.getElementById("fin").value = "Must Enter LTV";if(document.getElementById("fin").value == "NaN") document.getElementById("fin").value = "Values Needed";}</script></head><body bgcolor=#F0F8FF><big><big><u><b>How Much House Can My Borrower Afford?</b></u></big></big><br><form id = "ltv1"><table border="[1]" cellpadding=[5]><tr><td align=center><b>LTV:</b></td><td align=center><input type = text size = [2] id = "ltv" value = [0] onFocus="select()">%</td></tr></table></form><form id = "aa"><table border="[1]" cellpadding=[5]><tr><td align=center><select id = "sel1"><option value ="[15]" id = "yy" selected="selected">[15]</option><option value ="[30]" id = "yyy">[30]</option></select>Year Loan</td><td align=center><select id = "sel2"><option value ="[5].[0]" id = "ff1" selected="selected">[5].[0]</option><option value ="[5].[5]" id = "ff2">[5].[5]</option><option value ="[6].[0]" id = "ss1">[6].[0]</option><option value ="[6].[5]" id = "ss2">[6].[5]</option><option value ="[7].[0]" id = "sss1">[7].[0]</option><option value ="[7].[5]" id = "sss2">[7].[5]</option><option value ="[8].[0]" id = "ee1">[8].[0]</option><option value ="[8].[5]" id = "ee2">[8].[5]</option><option value ="[9].[0]" id = "nn1">[9].[0]</option><option value ="[9].[5]" id = "nn2">[9].[5]</option><option value ="[10].[0]" id = "tt1">[10].[0]</option><option value ="[10].[5]" id = "tt2">[10].[5]</option></select>%Rate</td></tr></table></form><big><b>Gross Monthly Income</b></big><form id = "a"><table border="[1]" cellpadding=[5]><td align=center><b><u>For Borrower</u></b></td><td align=center><input type=reset value="Clear"></td><tr><td align=center>Base Employment Income:</td><td align=center>$<input type = text id = "txt1" value = [0] onFocus="select()"></td></tr><tr><td align=center>Overtime:</td><td align=center>$<input type = text id = "txt2" value = [0] onFocus="select()"></td></tr><tr><td align=center>Part-Time:</td><td align=center>$<input type = text id = "txt3" value = [0] onFocus="select()"></td></tr><tr><td align=center>Commissions:</td><td align=center>$<input type = text id = "txt4" value = [0] onFocus="select()"></td></tr><tr><td align=center>Other:</td><td align=center>$<input type = text id = "txt5" value = [0] onFocus="select()"></td></tr></table></form><form id = "b"><table border="[1]" cellpadding=[5]><td align=center><b><u>For Co-Borrower</u></b></td><td align=center><input type=reset value="Clear"></td><tr><td align=center>Base Employment Income:</td><td align=center>$<input type = text id = "txt11" value = [0] onFocus="select()"></td></tr><tr><td align=center>Overtime:</td><td align=center>$<input type = text id = "txt22" value = [0] onFocus="select()"></td></tr><tr><td align=center>Part-Time:</td><td align=center>$<input type = text id = "txt33" value = [0] onFocus="select()"></td></tr><tr><td align=center>Commissions:</td><td align=center>$<input type = text id = "txt44" value = [0] onFocus="select()"></td></tr><tr><td align=center>Other:</td><td align=center>$<input type = text id = "txt55" value = [0] onFocus="select()"></td></tr></table></form><big><b>Monthly Obligations</b></big><form id = "c"><table border="[1]" cellpadding=[5]><td align=center><b><u>For Borrower</u></b></td><td align=center><input type=reset value="Clear"></td><tr><td align=center>Auto Loans:</td><td align=center>$<input type = text id = "txt111" value = [0] onFocus="select()"></td></tr><tr><td align=center>Installment Loans:</td><td align=center>$<input type = text id = "txt222" value = [0] onFocus="select()"></td></tr><tr><td align=center>Credit Cards:</td><td align=center>$<input type = text id = "txt333" value = [0] onFocus="select()"></td></tr><tr><td align=center>Other:</td><td align=center>$<input type = text id = "txt444" value = [0] onFocus="select()"></td></tr></table></form><form id = "d"><table border="[1]" cellpadding=[5]><td align=center><b><u>For Co-Borrower</u></b></td><td align=center><input type=reset value="Clear"></td><tr><td align=center>Auto Loans:</td><td align=center>$<input type = text id = "txt1111" value = [0] onFocus="select()"></td></tr><tr><td align=center>Installment Loans:</td><td align=center>$<input type = text id = "txt2222" value = [0] onFocus="select()"></td></tr><tr><td align=center>Credit Cards:</td><td align=center>$<input type = text id = "txt3333" value = [0] onFocus="select()"></td></tr><tr><td align=center>Other:</td><td align=center>$<input type = text id = "txt4444" value = [0] onFocus="select()"></td></tr></table></form><big><b>Your Borrower Can<br> Afford To Spend:</b></big><br><big><b>$</b></big><input type = text id = "fin" value = "" readonly><br><br><input type="button" value="  CALCULATE FORM  " onClick="main(this.form)"><!-- <td align=center><input type=reset value="CLEAR PAGE"></td> --><br><br><small><small>©[2005] Jake Johnson. All rights reserved.<br>Contact: <a href="mailto:jakejohnson2431@yahoo.com">Jake Johnson</a></small></small></body>