Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I focus on a textbox?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi there,

I wonder how to place the marker in a specific textbox.
I have tried in a couple of diffrent ways using focus() but can´t understand how to use it!

/krzinskij
 
Hi krzinskij,

try this sample :

<html>
<head>
<title>Focus Sample</title>
<script language=&quot;javascript&quot;>
function SetFocus(myArea) {
var myItem;
myItem = eval(&quot;document.forms[0].myTextarea_&quot; + myArea);
myItem.focus();
};
</script>
</head>

<body>
<form name=&quot;myForm&quot; action=&quot;myPage.htm&quot; method=&quot;post&quot;>
<textarea cols=&quot;30&quot; rows=&quot;5&quot; name=&quot;myTextarea_1&quot;>My First Textarea</textarea>
<br>
<br>
<textarea cols=&quot;30&quot; rows=&quot;5&quot; name=&quot;myTextarea_2&quot;>My Second Textarea</textarea>
<br>
<br>
<input type=&quot;button&quot; value=&quot;Focus 1&quot; name=&quot;Focus_1&quot; onclick=&quot;SetFocus(1);&quot;>
<br>
<br>
<input type=&quot;button&quot; value=&quot;Focus 2&quot; name=&quot;Focus_2&quot; onclick=&quot;SetFocus(2);&quot;>
</form>
</body
</html>

Hope this helps ...
 
Thank you...

I found out that I had misspelled the name of my textbox... that´s just typical!

/krzinskij
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top