��� ����: ����� ����� / ����� 4 / �� 10
 


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


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

����� 4

�� 10: ��� ����� ����� ���������� ���� �����.

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

function simpleSwap()
{
  var the_image = prompt("change parrot or cheese","");
  var the_image_name = "window.document." + the_image;
  var the_image_object = eval(the_image_name);
  the_image_object.src = "ant.gif";
}

��� ������, ���� ����� ������� ��"� ��� ����� ������� �����������, �� ����- window.document.images["parrot"].src. ����� ��� ����� ������� ��"� ���� ������� ���� ����� ������, �� ����- window.document.images[0].src. �� ��, ���� ����� ���� ������ ��� ��:

function simpleSwap()
{
  var the_image = prompt("change parrot or cheese","");
  window.document.images[the_image].src = "ant.gif";
}

��� ���� ������ ����� �� ���� ���� �� ���� ���� ���������. �� �� �� ���� ���� �����, ��� ��:

<form name="the_form">
<input type="text" name="the_text_box">
</form>

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

window.document.forms["the_form"].elements["the_text_box"].value = "hello!";

��� ��� ���� �� ���� ����� ���� ������ ���������� ����������. ����� ����� ����� ������ ������, ��� ������ ������ ����� ����� ����� ����� �����:

var the_form_name = "the_form";
var the_element_name = "the_text_box";

1) window.document.forms[0].elements[0].value = "hello!";
2) window.document.forms[the_form_name].elements[the_element_name].value = "hello!";
3) window.document.the_form.the_text_box.value = "hello!";
4) var the_element_string = "window.document." + the_form_name + "." + the_element_name;
   var the_element = eval(the_element_string);
   the_element_string.value = "hello!";

�� ����� ��� ����� ����� ���� ���� ���, ���� ������ ���, ����� ���������� ����� �� ����� ���.

�� ���� ������ ���� ����. ��� ���� ���� ����.

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

��� ��� «--

 
       
       
   
 
 

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