��� ����: ����� ����� / ����� 5 / �� 9
 


������ �� ��� �- JavaScript
 


���� ������ ��:
1: ���� ������ 5
2: ���� ������
3: ���������� �����
4: ����� ���� �����
5: ���� �����
6: ������� ���� �����
7: CheckBoxes
8: ������ ����
9: ������
10: ����� onChange
11: ����� �� ����� 5
|
|
|
|
|
|
|
|
|
|
|
|

����� 5

�� 9: ������.

������ �� ����� �� �������, ��� �������� ����� ������� �����. ���� ��� ����� ������� �������: ����� ���� (pulldown) ������ (list select). ��� ��� ������� ������ �� ��� ��� ������ �������:

Pulldown:

List:

���� ����� �������� ������� ����� �� �� ����� ��� ������ ���� ������� ������ ���� �� �� ���, ��� ��� �� ��� ��� ��������� ������ ���. ������, �- 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 ���� �� ������.

���� ������ ���

��� ��� «--

 
       
       
   
 
 

���� ����
����� �����
����� �����
����� ������
����� ���
��� ����