This free javascript will act upon a user selection in one select menu, to create the options in another menu. Works in Netscape 4 and above, IE 4 and above. This example use the "multiple" attribute to show several options at once. You can remove the attribute if you'd like standard drop drop down select menus.
You can control both the value and text portions of each new option. These select menus can also be database driven (dynamically produced using your database) using CGI.
This is the script that creates the new options
<script>
<!--
// Select menu Creator. Written by PerlscriptsJavascripts.com
// prepare possible new values
reps = new Object();
reps[0] = "Select a report ";
reps[1] = "Report A ";
reps[2] = "Report B ";
reps[3] = "Report C ";
reps[4] = "Report D ";
reps_vals = new Object();
reps_vals[0] = "";
reps_vals[1] = "a";
reps_vals[2] = "b";
reps_vals[3] = "c";
imgs = new Object();
imgs[0] = "Select an image ";
imgs[1] = "Image A ";
imgs[2] = "Image B ";
imgs[3] = "Image C ";
imgs[4] = "Image D ";
imgs_vals = new Object();
imgs_vals[0] = "";
imgs_vals[1] = "a";
imgs_vals[2] = "b";
imgs_vals[3] = "c";
imgs_vals[4] = "d";
// the function that does all the work
function addNewOptions(w) {
df = document.selForm;
if(w){
the_array = eval(w);
the_vals = eval(w + '_vals');
df.choose.options.length = 0;
for(i in the_array){
df.choose.options[i] = new Option(the_array[i],the_vals[i]);
if(document.all){
df.choose.options[i].style.background = "orange"
}
}
} else {
for(a = 0; a < df.choose.options.length; a++){
df.choose.options[a] = new Option("Select a report","");
}
df.choose.options.length = 1;
}
}
// -->
</script>
Subscribers log in here. Subscribe to our periodical newsletter for special offers on commercial scripts, hosting, exciting business opportunities, and industry news and events. Our Mailing List Software is powered by Consolidator