Здраствуйте. Вот есть такой простой скрипт:
| Код | <html> <head> <title>Форма с описанием затем подвыбор во второй форме с своим описанием.</title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> </head> <BODY >
<script language="JavaScript"> <!--
var num_of_cats = 3; // This is the number of categories, including the first, blank, category. var option_array = new Array(num_of_cats);
option_array[0] = new Array("параметр 1", "параметр 2"); // This is the first (blank) category. Don't mess with it. option_array[1] = new Array("параметр 1", "параметр 2"); option_array[2] = new Array("параметр 1", "параметр 2");
function switch_select() { for (loop = window.document.form_1.select_2.options.length-1; loop > 0; loop--) { window.document.form_1.select_2.options[loop] = null; }
for (loop = 0; loop < option_array[window.document.form_1.select_1.selectedIndex].length; loop++) { window.document.form_1.select_2.options[loop] = new Option(option_array[window.document.form_1.select_1.selectedIndex][loop]); }
window.document.form_1.select_2.selectedIndex = 0; }
function set_orig() { window.document.form_1.select_1.selectedIndex = 0; window.document.form_1.select_2.selectedIndex = 0; }
window.onload=set_orig // --> </script>
<form name="form_1" onSubmit="return false;">
<select name="select_1" onChange="switch_select();"> <option>значение 1</option> <option>значение 2</option> <option>значение 3</option> </select><br><br>
<select name="select_2" style="width:140px" > <option>select...</option> </select><br><br>
</form> </body></html>
|
Выбирая значения из перого комбобокса, вызывается функция switch_select, и во второй комбобокс при этом как то странно наполняется: появляются лишние пустые поля. Как от них избавиться? В Explorere вроде всё нормально работает, а вот в других браузерах нет. |