focus input

by dimachen

HTML

<form name = "TestForm" action="#">
<input type = "text" value="Текстовое поле 1" name="text1" />
<br />
<input type = "text" value="Текстовое поле 2" name="text2" />
<br />
<input type = "button" value = "Фокус на текстовом поле 1" name="myButton1"
onclick="FocustoTextbox(1)" />
<input type = "button" value = "Фокус на текстовом поле 2" name="myButton2"
onclick="FocustoTextbox(2)" />
</form>

JavaScript

function FocustoTextbox(x){
if(x == 1){
document.TestForm.text1.focus();
}else if(x == 2){
document.TestForm.text2.focus();
}
}