Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (41 sloc) 1.93 KB
title layout author authorurl
If mania
post
James

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

{% highlight javascript %} // 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! {% endhighlight %}

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