��� ����: ����� ����� / ����� 5 / �� 7
 


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


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

����� 5

�� 7: CheckBoxes.

���� ����� ������ ����� �� �� ��� ��� ����� �� ������� �����. ��� ������ ����� ��� ������ �� ���� �- checkboxes, ������ ���� ������� �����. ���� ���� ������ �-checkbox. �-checkbox ���� ����� ��� ������� ������: ������� ������ (check).

This checkbox is checked
This checkbox is not checked

�� �� �� ���� �����: the_form ��- checkbox ����: the_checkbox, ���� ����� �� �-checkbox ��� ���� �"� ���� ���:

var is_checked = window.document.the_form.the_checkbox.checked;
if (is_checked == true) {
  alert("Yup, it's checked!");
} else {
  alert("Nope, it's not checked.");
}

��� ���� ���� �� ������ �����, ������ ������ ���� ������� true. true ���� ��� ����� �- javaScript, ��� ��� ���� ���� ���� �������� ���� ��� ������ ���� ������ ���. �� �-checkbox ���� ����, ��� ������ ������ ���� false (�� ��� �����).

��� ���� ���� ����� �� ������ ����� �- checkboxes, �� �� ���� ����� �� ����. ���� ����� ������ ����� �� ������ ������.

������ ���� �� ������:

<form name="form_1">
  <input type="checkbox" name="check_1">Checkbox 1<br>
</form>

<a href="#" onClick="window.document.form_1.check_1.checked=true; return false;">Click to check Checkbox 1</a> <br>
<a href="#" onClick="window.document.form_1.check_1.checked=false; return false;">Click to uncheck Checkbox 1</a> <br>
<a href="#" onClick="alert(window.document.form_1.check_1.checked); return false;">Click to see the value of Checkbox 1</a>

��� �� ��� ���� ����� false ���� �- href, �"� ����� ���� ����� ���� ��� ���� �� �������.

�- checkbox �� ����� ������� ������: �- onClick. ���� ����� ���� �� �-checkbox ������ �� �- onClick �����. ��� �����:

The Light Switch

����� �� ����� ������ ���� ������ ��������: �����, ����� ������ �� �- onClick �� ����� ������� �� �- checkbox.

<form name="form_2">
  <input type="checkbox" name ="check_1" onClick="switchLight();">The Light Switch
</form>

���� ����� ���� �� �- checkbox ����� ������� �� onClick ����� ����� ����� �������� ()switchLight. ��� �������� ()switchLigt:

function switchLight()
{
  var the_box = window.document.form_2.check_1;
  var the_switch = "";
  if (the_box.checked == false) {
    alert("Hey! Turn that back on!");
    document.bgColor='black';
  } else {
    alert("Thanks!");
    document.bgColor='white';
  }
}

���� ������� ������ ����� ����� �������:

var the_box = window.document.form_2.check_1;

���� �� ���� �� ������� �- checkbox ������. ���� ��� ������ ���� ������. ����� ���, ��� �� ������ ������ ��������� �������� ���������. ����� ���� ��� ���� ������� ���� �������� �����.

��� ��� ����� ���� ���� ���� �� checkbox, ������, ����� ����� �� ������ �����.

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

��� ��� «--

 
       
       
   
 
 

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