if statement - Javascript - if/and/else not working -
first off ... i'm new javascript ...
here's code i'm using, doesn't seem working properly. here's i'm trying accomplish ...
if has 'typeset' value of "complete set" , it's 'main' value "a2 tandem", it's title variable should "line set w/ alinks: ". if has other 'typeset' value or it's 'main' value "a2 tandem", it's title variable should "line set: "
what's happening: doesn't seem differentiating between 'main' value being "a2 tandem". still applying "w/ alinks: " title if 'main' value "a2 tandem".
help?
if (acccat == "line sets"){ document.getelementbyid('o1').value = document.getelementbyid('main').value; document.getelementbyid('o2').value = document.getelementbyid('mainsize').value; document.getelementbyid('o3').value = document.getelementbyid('typeset').value; document.getelementbyid('o4').value = document.getelementbyid('typeline').value; var canopyvalue = document.getelementbyid('main').value; var title; if ((document.getelementbyid('typeset').value == "complete set") && (canopyvalue != "a2 tandem")){ title = "line set w/ alinks: "; }else{ title = "line set: "; }
if (acccat == "line sets"){ //<-------- didn't close document.getelementbyid('o1').value = document.getelementbyid('main').value; document.getelementbyid('o2').value = document.getelementbyid('mainsize').value; document.getelementbyid('o3').value = document.getelementbyid('typeset').value; document.getelementbyid('o4').value = document.getelementbyid('typeline').value; var canopyvalue = document.getelementbyid('main').value; var title; if ((document.getelementbyid('typeset').value == "complete set") && (canopyvalue != "a2 tandem")){ title = "line set w/ alinks: "; }else{ title = "line set: "; }
add }
end of code.
also quick tip:
instead of typing document.getelementbyid("someid").value
every single time, make function element.
var = function(id){ return document.getelementbyid(id); }
then can access get("o1").value = get("main").value
Comments
Post a Comment