adding text to textarea

dalton.lesko088

Baseband Member
Messages
55
Location
USA
Okay, noob question, but i have been trying to figure this out for a while... like hours. I want to press a button (ID of "validate"), and add text to a textarea (named "Rules") ONLY if a checkbox (named "displayRules") is checked. The forms name is validate. this is my code (Ignore the clear and the fill functions, i just want focus on the calculate function):

window.onload = function ()
{
document.getElementById("Clear").onclick= Clear;
document.getElementById("Fill").onclick= Fill;
document.getElementById("validate").onclick= Calculate;
}
function $ (id) {
return document.getElementById(id);
}
function Clear() {
$("FName").value="";
$("LName").value="";
$("phone").value="";
$("zip").value="";
$("email").value="";
$("social").value="";
$("income").value="";
$("year").value="";
}
function Fill () {
$("FName").value="Betty";
$("LName").value="Betters";
$("phone").value="123-456-7890";
$("zip").value="12345-7890";
$("email").value="bbetters@example.com";
$("social").value="123-45-6789";
$("income").value="50000";
$("year").value="1990";
}
function Calculate () {
if ($("FName").validity.valid = false) {
alert("Fill out First name form according to rules")
}
if (document.validate.displayRules.checked == true) {
$("Rules").innerHTML = "If income your income is less than or equal to $20,000, your Tax is equal to 10% of your income." + "<br>" + "If your income is greater than $20,000 but less than or equal to $50,000, your tax is equal to $2,000 plus 20% of however much your income is over $20,000." + "<br>" + "If your income is greater than $50,000 but less than or equal to $100,000 , your tax is $8,000 plus 25% of however much your income is over $50,000." + "<br>" + "If your income is greater than $100,000 but less than or equal to $500,000 , your tax will be $20,500 plus 30% of however much of your income is over $100,000." + "<br>" + "If your income is over $500,000 then you are only taxed 1% of your income.";
}
}
 
Last edited:
Should be able to use the Dev Tools in the browser and put a Breakpoint on the JavaScript function and see if it's hitting it or not.
 
Back
Top Bottom