This topic is locked

Focus on specific field in _add page

11/14/2005 10:32:14 AM
ASPRunnerPro General questions
orit author

How can I define a field (textarea) that will get the focus when the _add page is loaded?
Thanks

Sergey Kornilov admin 11/14/2005

You can use something like this (see my changes in bold:

<body onLoad="java script:document.forms.editform.fieldname.focus();">


Please note that field names are case-sensitive in Javascript.

orit author 11/17/2005

On that add page I already have a function in the onload:

<body bgcolor=white onLoad="define('CommentID', 'IsRequired', '<%=Label("CommentID")%>');">


I didn't succeed that both of them will work.
Can you please suggest how to make them both working?
Thanks

Sergey Kornilov admin 11/17/2005

Try the following:

<body bgcolor=white onLoad="define('CommentID', 'IsRequired', '<%=Label("CommentID")%>');

document.forms.editform.fieldname.focus();">
orit author 11/23/2005

Still doesn't work, I'm getting the error:

"Error: Can't move focus to the control because it is invisible, not enabled, or of a type that doesn't accept the focus"
What is the problem?
Thanks

Sergey Kornilov admin 11/23/2005

I just double checked - it works perfect with text and textarea fields in Internet Explorer. What browser do you use?
Make sure this field is visible and enabled.

orit author 11/27/2005

I use Internet Explorer.

The field is a textarea using reach text editor.

I didn't set it as disabled or invisble,
Any idea?
Thanks

Sergey Kornilov admin 11/27/2005

Could you send me a URL where I can see this?

orit author 11/29/2005

Unfortunately no, It's on the Intranet..
Thanks

Sergey Kornilov admin 11/30/2005

Build a test project using a sample MS Access database. Modify code according to my post. If it doesn't work - zip and send me all ASP files and database for investigation.