/Ugly/ + 'JavaScript'

A place for ugly, silly, or just-plain-crap JavaScript.

If mania

Some people enjoy if statements and have an unhealthy obsession with redundant parentheses…

// this function checks which class and subject u have selected
// and set the value of book accordingly and the name of file that will be open after button clicked
    
if((document.test.tclass.value==1) && (document.test.tsubject.options[sind].text=="English"))
{
    document.test.tbook.options[0].text="..Select Book Title..";
    document.test.tbook.options[1].text="Marigold";
    document.test.tbook.options[1].value="textbook.htm?aeen1=0-10"                
}
else if((document.test.tclass.value==1) && (document.test.tsubject.options[sind].text=="Mathematics"))
{
    document.test.tbook.options[0].text="..Select Book Title..";
    document.test.tbook.options[1].text="Math-Magic";
    document.test.tbook.options[1].value="textbook.htm?aemh1=0-13"        
    document.test.tbook.options[2].text="Ganit Ka Jaadu";
    document.test.tbook.options[2].value="textbook.htm?ahmh1=0-13"               
}
else if((document.test.tclass.value==1) && (document.test.tsubject.options[sind].text=="Hindi"))
{
    document.test.tbook.options[0].text="..Select Book Title..";
    document.test.tbook.options[1].text="Rimjhim";
    document.test.tbook.options[1].value="textbook.htm?ahhn1=0-23"        
}
else if((document.test.tclass.value==1) && (document.test.tsubject.options[sind].text=="Urdu"))
{
    document.test.tbook.options[0].text="..Select Book Title..";
    document.test.tbook.options[1].text="Ibtedai Urdu-I";
    document.test.tbook.options[1].value="textbook.htm?aulb1=0-27"        
    document.test.tbook.options[2].text="Riyazi";
    document.test.tbook.options[2].value="textbook.htm?auri1=0-17"    
}
/// ... it continues!

Some lookup table, e.g. in JSON, would probably suffice for managing this type of functionality.

Posted by James on 10 Sep 2011 | linky

Subscribe or follow @UglyJS!
.........
Fork then send a pull request to contribute.