Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
why isn't my javascript working?!?
Here is my javascript. My goal was to create a form with a text input and three submit buttons.
Each button will perform a different conversion on the text. Here's my script. It looks like to me like it should work. but I wanna get some fresh eyes on it.
//<![CDATA[
var numInput;
var numOutput;
var conversionText;
function convFt2In(){
numInput = document.getElementById("Input").value;
document.getElementById("Input").value = "duh!";
numOutput = numInput * 12;
if(numInput!=1){
cText = " Feet are equal to ";
} else {
cText2 = " Foot is equal to ";
}
if(numOutput!=1){
cText = " Inches";
} else {
cText2 = " Inch";
}
WriteData();
}
function convMi2Ft(){
numInput = document.getElementById("Input").value;
numOutput = numInput * 5280;
if(numInput!=1){
cText = " Miles are equal to ";
} else {
cText2 = " Mile is equal to ";
}
if(numOutput!=1){
cText = " Feet";
} else {
cText2 = " Foot";
}
WriteData();
}
function convMi2Km(){
numInput = document.getElementById("Input").value;
numOutput = numInput * 1.609344;
if(numInput!=1){
cText = " Miles are equal to ";
} else {
cText2 = " Mile is equal to ";
}
if(numOutput!=1){
cText = " Kilometers";
} else {
cText2 = " Kilometer";
}
WriteData();
}
function WriteData(){
if (numInput<0){
document.getElementById("Input").innerHTML = "Please enter a valid number above 0";
} else {
document.getElementById("Input").innerHTML = numInput+cText+numOutput+cText2;
}
document.write(numInput);
}
document.write("<form id='Converter' name='Converter' method='post'>"+
"<p><label id='Output'>hey</label></p><input type='text' name='Input' id='Input' /><br/>"+
"<input type='button' name='convFt2In' id='convFt2In' value='Convert Feet to Inches' onclick='convFt2In();' />"+
"<input type='button' name='convMi2Ft' id='convMi2Ft' value='Convert Miles to Feet' onclick='convMi2Ft();' />"+
"<input type='button' name='convMi2Km' id='convMi2Km' value='Covert Miles to Kilometers' onclick='convMi2Km();' /></form></br>");
//]]>