var d = new dynamicSelect(); d.addSelect('racetype'); d.selects['racetype'].addOption('1'); d.selects['racetype'].options['1'].createOption('', '0'); d.selects['racetype'].options['1'].createOption('Mini Sprint', '1'); d.selects['racetype'].options['1'].createOption('Sprint', '2'); d.selects['racetype'].options['1'].createOption('Olympic', '3'); d.selects['racetype'].options['1'].createOption('1/2 Ironman', '4'); d.selects['racetype'].options['1'].createOption('Full Ironman', '5'); d.selects['racetype'].options['1'].createOption('Short Course', '6'); d.selects['racetype'].options['1'].createOption('Long Course', '7'); d.selects['racetype'].options['1'].createOption('Winter', '8'); d.selects['racetype'].options['1'].createOption('Winter Maintenance', '9'); d.selects['racetype'].options['1'].createOption('Other', '99'); d.selects['racetype'].addOption('2'); d.selects['racetype'].options['2'].createOption('', '0'); d.selects['racetype'].options['2'].createOption('Standard', '1'); d.selects['racetype'].options['2'].createOption('Xterra', '3'); d.selects['racetype'].options['2'].createOption('Winter', '4'); d.selects['racetype'].options['2'].createOption('Powerman', '5'); d.selects['racetype'].options['2'].createOption('Other', '99'); d.selects['racetype'].addOption('3'); d.selects['racetype'].options['3'].createOption('', '0'); d.selects['racetype'].addOption('4'); d.selects['racetype'].options['4'].createOption('', '0'); d.selects['racetype'].addOption('5'); d.selects['racetype'].options['5'].createOption('', '0'); d.selects['racetype'].addOption('6'); d.selects['racetype'].options['6'].createOption('', '0'); d.selects['racetype'].options['6'].createOption('3 Mile', '1'); d.selects['racetype'].options['6'].createOption('5k', '2'); d.selects['racetype'].options['6'].createOption('3.5 Mile', '3'); d.selects['racetype'].options['6'].createOption('4 Mile', '4'); d.selects['racetype'].options['6'].createOption('8k', '5'); d.selects['racetype'].options['6'].createOption('5 Mile', '6'); d.selects['racetype'].options['6'].createOption('10k', '7'); d.selects['racetype'].options['6'].createOption('15k', '8'); d.selects['racetype'].options['6'].createOption('10 Mile', '9'); d.selects['racetype'].options['6'].createOption('20k', '10'); d.selects['racetype'].options['6'].createOption('Half Marathon', '11'); d.selects['racetype'].options['6'].createOption('15 Mile', '12'); d.selects['racetype'].options['6'].createOption('25k', '13'); d.selects['racetype'].options['6'].createOption('30k', '14'); d.selects['racetype'].options['6'].createOption('20 Mile', '15'); d.selects['racetype'].options['6'].createOption('25 Mile', '16'); d.selects['racetype'].options['6'].createOption('Marathon', '17'); d.selects['racetype'].options['6'].createOption('Ultra Marathon', '18'); d.selects['racetype'].options['6'].createOption('Other', '99'); d.selects['racetype'].addOption('7'); d.selects['racetype'].options['7'].createOption('', '0'); d.selects['racetype'].options['7'].createOption('50 Freestyle', '1'); d.selects['racetype'].options['7'].createOption('100 Freestyle', '2'); d.selects['racetype'].options['7'].createOption('200 Freestyle', '3'); d.selects['racetype'].options['7'].createOption('400 Freestyle', '4'); d.selects['racetype'].options['7'].createOption('800 Freestyle', '5'); d.selects['racetype'].options['7'].createOption('1000 Freestyle', '6'); d.selects['racetype'].options['7'].createOption('1650 Freestyle', '7'); d.selects['racetype'].options['7'].createOption('50 Backstroke', '8'); d.selects['racetype'].options['7'].createOption('100 Backstroke', '9'); d.selects['racetype'].options['7'].createOption('200 Backstroke', '10'); d.selects['racetype'].options['7'].createOption('400 Backstroke', '11'); d.selects['racetype'].options['7'].createOption('800 Backstroke', '12'); d.selects['racetype'].options['7'].createOption('50 Breast', '13'); d.selects['racetype'].options['7'].createOption('100 Breast', '14'); d.selects['racetype'].options['7'].createOption('200 Breast', '15'); d.selects['racetype'].options['7'].createOption('50 Fly', '16'); d.selects['racetype'].options['7'].createOption('100 Fly', '17'); d.selects['racetype'].options['7'].createOption('200 Fly', '18'); d.selects['racetype'].options['7'].createOption('1 Hour Postal', '19'); d.selects['racetype'].options['7'].createOption('3000 Yard Postal', '20'); d.selects['racetype'].options['7'].createOption('6000 Yard Postal', '21'); d.selects['racetype'].options['7'].createOption('2.5k Postal', '22'); d.selects['racetype'].options['7'].createOption('5k Postal', '23'); d.selects['racetype'].options['7'].createOption('10k Postal', '24'); d.selects['racetype'].options['7'].createOption('1 mile Cable', '25'); d.selects['racetype'].options['7'].createOption('2 mile Cable', '26'); d.selects['racetype'].options['7'].createOption('Other', '99'); d.selects['racetype'].addOption('8'); d.selects['racetype'].options['8'].createOption('', '0'); d.selects['racetype'].options['8'].createOption('Road Race', '1'); d.selects['racetype'].options['8'].createOption('Century', '2'); d.selects['racetype'].options['8'].createOption('Criterium', '3'); d.selects['racetype'].options['8'].createOption('Time Trial', '4'); d.selects['racetype'].options['8'].createOption('Tour', '5'); d.selects['racetype'].options['8'].createOption('Cyclocross', '6'); d.selects['racetype'].options['8'].createOption('Mountain Biking', '7'); d.selects['racetype'].options['8'].createOption('Gravel', '8'); d.selects['racetype'].options['8'].createOption('Other', '99'); d.selects['racetype'].addOption('9'); d.selects['racetype'].options['9'].createOption('', '0'); d.selects['racetype'].addOption('10'); d.selects['racetype'].options['10'].createOption('', '0'); d.selects['racetype'].addOption('11'); d.selects['racetype'].options['11'].createOption('', '0'); function dynamicSelect() { this.selects = new Array(); this.addSelect = function(name) { this.selects[name] = new selectObj(); } this.updateOptions = function(source, target) { var form = source.form; var target = form.elements[target]; var value = source.options[source.selectedIndex].value; while(target.options.length) target.remove(0); if(!this.selects[source.name].options[value]) { //alert('Invalid selection.'); //For debugging while you set it up return; } var data = this.selects[source.name].options[value].options; for(var x=0; x