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

form focus 1

Status
Not open for further replies.

calista

Programmer
Jan 24, 2001
545
US
I have a form with only one element, and I automatically put the focus in that element. This is for a comment field which may already have something in it that may be edited, and the form is pre-filled if there is. How do I modify my script to put the focus at the end of the comment if there is existing data?

Probably something simple, but I'm new at this.

Here is the script:
<head>
<title>Edit Comments</title>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Begin
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
isNav4 = (navigator.appName == &quot;Netscape&quot;) ? 1 : 0;
isIE4 = (navigator.appName.indexOf(&quot;Microsoft&quot;) != -1) ? 1 : 0;
}
function fitWindowSize() {
if (isNav4) {
window.innerWidth = document.layers[0].document.images[0].width;
window.innerHeight = document.layers[0].document.images[0].height;
}
if (isIE4) {
window.resizeTo(600,500);
}
document.MyForm.Comments.focus();

}
// End -->
</script>
</head>

<BODY ONLOAD=&quot;fitWindowSize()&quot;>

Thanks! Calista :-X
Jedi Knight,
Champion of the Force
 
Hi Calista,

Just add this line after document.MyForm.Comments.focus();

document.MyForm.Comments.value = document.MyForm.Comments.value;

hope this helps,
 
Thanks, Pepper! I knew it had to be something simple. Calista :-X
Jedi Knight,
Champion of the Force
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top