I am trying to make a Measurements Units Conversion Calculater on Dreamweaver with help of Javascript.
THis is my first ever javascript application and need to complete it in next 6 hours. :((
I want to have a drop box containing Length, Area, Temp etc. on top. When a user selects any of this entities the dropdown lists below will fill with the respective units, ie. milimeters and meters for length, celsius and kelvin for temperature etc.
I have been able to acheive this goal in Firefox, but a big problem occurs that is when the list fills with the respective units, I am not able to select units except the initially selected first unit. Secondly this isn't working in IE 8(I know IE sucks big time but I want to make it workable on it too).
Any Help in this regard would be greatly appreciated. :)
The javascript is:
function setOptions(chosen) {
var selbox = document.form1.Iunit;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' ');
}
if (chosen == "1") {
selbox.options[selbox.options.length] = new Option('Milimeters','mm');
selbox.options[selbox.options.length] = new Option('Meters','m');
selbox.options[selbox.options.length] = new Option('KiloMeters','Km');
selbox.options[selbox.options.length] = new Option('Feet','f');
selbox.options[selbox.options.length] = new Option('Yards','y');
selbox.options[selbox.options.length] = new Option('Miles','mi');
}
if (chosen == "2") {
selbox.options[selbox.options.length] = new Option('Square Milimeters','mm2');
selbox.options[selbox.options.length] = new Option('Square Meters','m2');
selbox.options[selbox.options.length] = new Option('Square KiloMeters','km2');
selbox.options[selbox.options.length] = new Option('Square Inches','in2');
selbox.options[selbox.options.length] = new Option('Square Feet','f2');
selbox.options[selbox.options.length] = new Option('Square Yard','y2');
selbox.options[selbox.options.length] = new Option('Acre','a');
selbox.options[selbox.options.length] = new Option('Hectare','h');
selbox.options[selbox.options.length] = new Option('Square Miles','mi2');
}
if (chosen == "3") {
selbox.options[selbox.options.length] = new Option('Fluid Ounces','fo');
selbox.options[selbox.options.length] = new Option('MiliLitres','ml');
selbox.options[selbox.options.length] = new Option('Litres','l');
selbox.options[selbox.options.length] = new Option('Gallons','g');
selbox.options[selbox.options.length] = new Option('Cubic Meters','cm');
selbox.options[selbox.options.length] = new Option('Cubic Feet','cf');
selbox.options[selbox.options.length] = new Option('Cubic yards','cy');
}
if (chosen == "4") {
selbox.options[selbox.options.length] = new Option('grams','g');
selbox.options[selbox.options.length] = new Option('Kilograms','kg');
selbox.options[selbox.options.length] = new Option('Ounces','o');
selbox.options[selbox.options.length] = new Option('Pounds','p');
selbox.options[selbox.options.length] = new Option('Short Tons','st');
selbox.options[selbox.options.length] = new Option('Metric ton - Mega ton','mt');
}
if (chosen == "5") {
selbox.options[selbox.options.length] = new Option('Fahrenheit','df');
selbox.options[selbox.options.length] = new Option('Celsius','dc');
selbox.options[selbox.options.length] = new Option('Kelvin','dk');
}