View Full Version : onFocus()
chrismiceli
09-19-2002, 10:46 PM
is that a function, i want to use a function that when the person focuses (clicks) on a text field it will perform a function, is there an onFocus() or something i could do here?
Try This:
<script>
function dothis(){
alert("Hello World")
}
</script>
<form name="focusing">
<INPUT TYPE="text" NAME="t1" value="Click Me" onclick="dothis()">
<P><INPUT TYPE="text" NAME="t2" value="Tab To Me" onfocus="dothis()">
</form>
ASAAKI
09-19-2002, 11:10 PM
onFocus is an event (or is it 'event-handler'?), it's the thing that gets triggered when the user gets into the textbox (well, not literally :D). supposing u want to alert the user about something when he focuses, u'll do this:
<input type="text" name="quicksand" onfocus="alert('Look out!')">
there are lots of on...thingies to use with textboxes: onclick, onselect, onblur, onkeyup, i'm sure there's onkeypress and onkeydown as well.
i noticed u said onFocus()--with the brackets at the end.
focus() and onfocus are two different things.
try this and u'll see:
<form name="myform">
<input type="text" name="text1">
<input type="text" name="text2">
<input type="button" value="focus on text1" onclick="document.forms.myform.text1.focus()">
<input type="button" value="focus on text1" onclick="document.forms.myform.text2.focus()">
</form>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.