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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Focus 1

Status
Not open for further replies.

jossi

Programmer
May 24, 2001
8
PE
Help me!!!!
i nees to put the focus at the end of a word in a input text....
how can i do??
pleaseeeeeeeeeeeee!!!!!!!!!!!!!!!!
 
I know of a way to do this in IE, but I don't think it can be done in NS. Do you need this one cross browser?
- tleish
 
Hi Tlesh... i use IE.. please could you tell me how can i do it in IE??
i need it...it's so important..
Thanks a lot
Jossi
 
Hi Jossi,

try this, it works for IE and Netscape6, except Netscape4.x
<html>
<head>
<script Language=&quot;JavaScript&quot;>
function setDefault() {
document.MyForm.MyText.focus();
document.MyForm.MyText.value = document.MyForm.MyText.value;
}
</script>
</head>
<body onload=&quot;setDefault()&quot;>
<form name=&quot;MyForm&quot;>
<input type=&quot;text&quot; size=&quot;30&quot; value=&quot;Say No to Netscape 4!&quot; name=&quot;MyText&quot;>
</form>
</body>
</html>

hope this helps, Chiu Chan
WebMaster & Software Engineer
emagine solutions, inc
cchan@emagine-solutions.com
 
PepperPepsi
Thank so much ...i do it...it really works :-D
Thanks a lot
jossi
 
Sorry, I was aeay for a while. PepperPepsi showed you pretty much the same script I was going to do.

I would set it up so that you could pass the form element to the function, so that you can use it with more than one form element:

<html>
<head>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
function endFocus(vTextField) {
vTextField.focus();
vTextField.value += &quot;&quot;;
}

//-->
</SCRIPT>

</head>
<body onload=&quot;endFocus(document.MyForm.MyText)&quot;>

<form name=&quot;MyForm&quot;>
<input type=&quot;text&quot; size=&quot;30&quot; value=&quot;Say No to Netscape 4!&quot; name=&quot;MyText&quot;>
</form>

</body>
</html>

- tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top