<!DOCTYPE html> <!-- modofied on 8/15/2020. noy only "prt()"is working, but also radio buttons are OK --> <html> <head> <title>SSB Tax </title> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"/> <meta name="description" content="SL. August 7-9, 2020. Braselton, GA"/> <link rel="stylesheet" type="text/css" href="style.css"> <style> p {font-size: 18px;} label { display: table-cell; } button{ border: 1px solid navy; font-size: 16px;} input { display: table-cell; border: 1px solid navy;} </style> </head> <body> <div class="container"> <p> First, please select your fining status.<br> 请首先选择你的报税类别:</p> <form> <fieldset id="group1"> <p><input type="radio" id="single" name="group1" value="single"> Single Return (单 身)</p> <p><input type="radio" id="joint" name="group1" value="joint"> Joint Return (夫妻合报)</p> </fieldset> </form> <p><label> Then enter total SSB amount (全部社安收入): </label><input id = "SSBTotal"> </p> <p><label> Enter Other income, excl. SSB (社安收入以外的收入): </label> <input id = "F1040Income"></p> <p><label> Enter Tax-exempt interest (免税的利息收入): </label> <input id = "TaxExemInt"></p> <p><label> Enter Adjustment (收入减免): </label> <input id = "TotalAdjust"><br></p> </div> <button onclick = "ssb()">continue<br>继 续</button> <p id = "ssb"></p> <script> function prt(opt) { myOutput = document.getElementById("ssb"); //"Id" is the same as pre-defined in the HTML code above. myOutput.innerHTML += opt; //1."myOutput" can be any identifier. 2. it is important to use "+=", not "=". } function small(a, b) { var small; if (a <= b) { small = a; } else { small = b; } return small; } function ssb() { var radio1 = document.getElementById("single").checked; var radio2 = document.getElementById("joint").checked; if (radio1 == false && radio2 == false) { alert("You must select your filing status! Please start over."); document.getElementById("continue").onclick = function () { location.href = "ssb_tax_working_new_code.html"; } } var Line = new Array(); //Do not use "var Line = [];" Line[1] = document.getElementById("SSBTotal").value; if (isNaN(Line[1]) == true || Line[1] <= 0) { //input box 1, total ssb alert("You must enter a number greater than 0 in the box. Please start over!"); document.getElementById("continue").onclick = function () { location.href = "ssb_tax_fnl2.html"; }; } Line[2] = 0.5 * Line[1]; Line[3] = document.getElementById("F1040Income").value; Line[4] = document.getElementById("TaxExemInt").value; if (isNaN(Line[3]) == true || Line[3] <= 0) { //input box 2, 1040 income alert("You must enter a number greater than 0 in the box. Please start over!"); document.getElementById("continue").onclick = function () { location.href = "ssb_tax_fnl2.html"; }; } if (isNaN(Line[4]) == true || Line[4] < 0) { //input box 3, tax exemple interest alert("You must enter a number equal or greater than 0 in the box. Please start over!"); document.getElementById("continue").onclick = function () { location.href = "ssb_tax_fnl2.html"; }; } if (Line[4].length == 0) { // if(input.value.length == 0) Line[4] = 0; } //Line[5] = Line[2] + Line[3]) + Line[4]; //It does not work. "parseFloat()" must be used for Liine[3]and Line[4]. Line[5] = Line[2] + parseFloat(Line[3]) + parseFloat(Line[4]); //It is critical to use "parseFloat()". Line[6] = document.getElementById("TotalAdjust").value; if (isNaN(Line[6]) == true || Line[6] < 0) { //input box 4, income adjustment alert("You must enter a number equal or greater than 0 in the box. Please start over!"); document.getElementById("continue").onclick = function () { location.href = "ssb_tax_fnl2.html"; }; } if (Line[6].length == 0) { Line[6] = 0; } Line[7] = Line[5] - Line[6]; if (radio1 == true) { Line[8] = 25000; } if (radio2 == true){ Line[8] = 32000; } if (Line[7] < Line[8]) { //document.write("Congratulations!<br> You do not have to pay any SSB tax.<br> Goog bye!<br><br>"); prt("<p>Congratulations!<br> You do not have to pay any SSB tax.<br> Goog bye!</p>"); end; } else { //document.write("Your income is high enough.<br> So, you need to pay some SSB tax. <br><br>"); prt("<p>Your income is high enough.<br> So, you need to pay some SSB tax. </p>"); } Line[9] = Line[7] - Line[8]; if (radio1 == true){ Line[10] = 9000; } if (radio2 == true) { Line[10] = 12000; } if (Line[9] > Line[10]) { Line[11] = Line[9] - Line[10]; } else { Line[11] = 0; } Line[12] = small(Line[9], Line[10]) Line[13] = 0.5 * Line[12]; Line[14] = small(Line[2], Line[13]); Line[15] = 0.85 * Line[11]; Line[16] = Line[14] + Line[15]; Line[17] = 0.85 * Line[1]; Line[18] = small(Line[16], Line[17]); prt("<p>Your taxable SSB is: $" + Line[18] + "</p>"); prt("<p>The calculation is listed below. <br>The line number is the same as in the IRS worksheet. </p>"); var i for (i = 1; i <= 18; i++){ //document.write("<p>Line " + i + "= $" + Line[i] + "</p>"); prt("<p>Line " + i + "= $" + Line[i] + "</p>"); } } </script> </body> </html> </textarea">