����� 5
�� 9: ������.
������ �� ����� �� �������, ��� �������� ����� ������� �����. ���� ��� ����� ������� �������: ����� ���� (pulldown) ������ (list select). ��� ��� ������� ������ �� ��� ��� ������ �������:
���� ����� �������� ������� ����� �� �� ����� ��� ������ ���� ������� ������ ���� �� �� ���, ��� ��� �� ��� ��� ��������� ������ ���. ������, �- HTML ������ ������� ���� ��:
<select name="pulldown_1" size=1>
<option>probiscus
<option>spider
<option>lemur
<option>chimp
<option>gorilla
<option>orangutan
</select>
������ ���, �� ������ ����� ���: pulldown_1, ��� ������� ������������ ���� ��. �� �� ���� ���� ����� �������� ������������.
������, ���� ���� ������� �����������, �� ��������� ���� ������ �� �������� ������. �� ������ ����� ������� ������ ������ �- pulldown, �� ������ ����� ���:
window.document.form_1.pulldown_1.options[1].text = 'new_text';
������ ����� ���� �������� ������ �� ������ ��������� ��� ���� ���� ��� ��������� ������. ��� ���� ���� �� ��� ��������� ������ ������ �� ������ ����� ���, (������� �������) ��� ���. ��� �� ������ ��� ��� ����� ����� �� ������ �� �- pulldown ���� �����. ������� ������ �-pulldown ����� ����� ����� "*thau*" (��� ������� �����).
����� ������� ���������, ������ �� ����� ����� ������: ������ ������� (select Index). ���� ������ ��� �����, �� ������ ������ ������� ���� ����� ������ �� ������� ������. �� ��� ����� ���, ���� ����� �� ��� ��������� ������ ������ (������� ������), ��� ����� �� �������. ����, �������� ������� ����� ���� ������ 0. ���� ����� ��� ������� ����� ������:
<a href="#" onClick="alert('index is: ' + window.document.form_1.list_1.selectedIndex); return false;">check the index</a>
�� ����� ���: form_1, ������ ������ ����� ���: list_1. �� ��� ���� �� ������ ������ ������� �:
window.document.form_1.list_1.selectedIndex
�� ��� ���� ��� ���� ����� �� ������ ������ �"�:
window.document/form_1/list_1/selectedIndex=1;
������� �� ������� ������ ������ ��list_1. ���� ���� ��� ���� �� ������ ����� ������ ���������, ���� ����� �� ��� �����:
var the_select = window.document.form_1.list_1;
var the_index = the_select.selectedIndex;
var the_selected = the_select.options[the_index].text;
������ ������ ������� ���� ������ ���� �� �� ����� ��� ����. ����, �� ���� ���� �� �� ���� ������� ���? ���� �� ���� ��� ���� ���� �����. �� ���� �� �� ��� ������ ��.
��� ��� �������� �� ������, ������� ������ �� ����� (handler) �: ()onChange. ������ ��� ����� ���� �� ����� ������. ������ ��� ���� ����� ������ ��� ����� �� ��� onChange ���� �� ������.
���� ������ ���
��� ��� «--
|