I'm trying to do something in my mind that is very simple for some reason i am not getting the desired results? I am new to javascript but experienced with java so I believing i'm not using a correct rule of some sort.
This is a simple function to get the entered values, check to see which radio button was selected, and adding its price(value) to my var input;. This is all working, however my three lines of code, document.getElementById("outar").innerHTML = "Small Pizza";/Medium Pizza/and Large Pizza don't output the string "Small Pizza" to my element id = outar.
Edit1: As i was reviewing this waiting for a reply i noticed that i call document.getElementById("outar").innerHTML twice, once in hopes of displaying the String i give it, and then the next displaying the input. Would this override one another and be the reason why i'm only seeing input displayed? *****
function calculate()
{
var input = 0;
if (document.getElementById("small").checked)
{
alert("yay"); /*testing to see if i made it into the if statements*/
input += parseInt(document.getElementById("small").value);
document.getElementById("outar").innerHTML = "Small Pizza";
document.getElementById("outar").innerHTML = input;
}
else if (document.getElementById("med").checked)
{
input += parseInt(document.getElementById("med").value);
document.getElementById("outar").innerHTML = "Medium Pizza";
document.getElementById("outar").innerHTML = input;
}
else if (document.getElementById("large").checked)
{
input += parseInt(document.getElementById("large").value);
document.getElementById("outar").innerHTML = "Large Pizza";
document.getElementById("outar").innerHTML = input;
}
else
{
alert("failed");
}
}
I am trying to output these new strings to my html element with the id outar
<th rowspan="10" id="outp"><h3>Order Details</h3><p id="outar"></p></th>