����� 5
�� 4: ����� ���� ����� (Text Field Events).
���� ����� ������ �� �������: onBlur, onFocus ��� onChange. ����� �- onFocus ����� ���� ����� ���� ���� ���� �����. onBlur ����� ���� ����� ���� ����� ����� �"� ����� ���� ���� �� �"� ���� �� ��� �- Tab. onChange ����� ���� ����� ���� ���� ���� ���� ����� ����� ���� ���� ����� �����.
��� ����� �� �� ������ ������ ���� ���� ��� ����� ���, ���� �� ����� ������� �����.
��� �� ����. ���� ����� ����� ��:
<input type="text" name="first_text"
onFocus="writeIt('focus');"
onBlur="writeIt('blur');"
onChange="writeIt('change');">
�� ��� ��- event handlers ���� �������� �- ()writelt , ������� ���� ����� (header). ��� ����� ���� ��:
<head>
<title>Text Field Events</title>
<script language="JavaScript">
<!-- hide me
function writeIt(the_word)
{
var word_with_return = the_word + "\n";
window.document.first_form.the_textarea.value += word_with_return;
}
// show me -->
</script>
</head>
�� �� ���� ����� ���� ���� ��. ������ �������� ������ ����� ����� ��� �������� ������ �� JavaScript ������ ���������. ����� ������� ���� ��������,
var word_with_return = the_word + "\n";
������ ���� �� ������, word_with_return, ������ �� �� ���� ��� ����� ������ '\n' �����. (���� ������ '/n' ���� ����� ������� ����� �����).
����� ���� ���:
window.document.first_form.the_textarea.value += word_with_return;
���� �� �����: "��� ���� ���� �� ����� ����� �� ���� ������ ����� �� ������ ����". ����� ����� �� ���� ���� ����� �� �������. �� ����� ��� �����:
windows.document.first_form.the_textarea.value = window.document.first_form.the_textarea.value + word_with_return;
�� �� ���� ���� ���. �� �����, ����� ������ ���� �� ���� ���� ������ ���� (����) ���� ������� ����� ���� ������ ����� ������ ���. ���� ������ ������ ���� ����� ������� ���, ��� ������� ������ �� ������: ����� ()blur, ����� ()focus ������ ()select.
��� ,��� ������ �� ��� ������ ���� ������ ������ �- ()focus ��- ()select. �����, ������ �� ������� ����� ���� ��� ���.
��� ��� ����� ���� �������:
<form name="method_form">
<input type="text" name="method_text" size=40 value="Hey, hey, we're the monkeys">
</form>
<a href="#" onMouseOver="window.document.method_form.method_text.focus();"> Mouseover to focus</a>
<a href="#" onMouseOver="window.document.method_form.method_text.select();"> Mouseover to select</a>
����� ������� �� ���� ����� ��� ��� ����� ������� �� �� ������� ���:
obeject_name.method()
window.document.form_name.text_field_name
�� ��� ��� ����� ������ �- ()focus ����� ����� ������� ����, �����:
window.document.method_form.method_text.focus();
��� ��� ����� ��� ���� �� ���� ���� ������ ����. ����� ���� ������ ����� �� ������ ������ ������ ��. ���� �� �� ��� ��� ���� ���� ���� �� ����� ����� (form handlers) ���� ����� ����� �� ������.
���� ������ ���
��� ��� «--
|