PDA

View Full Version : [1.1.1] javascript focus() method doesn't work



hnd
8 Dec 2007, 1:52 AM
hi

jsscript function element.focus() doesn't work :((, when i try to set the focus control to the form field such like input or selection component (form elements)?.

The following form inside ext core


<head>
....
...
Ext.EventManager.onDocumentReady(Main.init, Main, false);
</head>
<body>
<div id ="container">
<div id="center" class="x-layout-inactive-content">
<div class="">
<form name="fform" method="post" action="">
<input type="text" name="text1" id="text1" value="">
<input type="submit" name="submit" value="Submit">
</form>
<script language="javascript">
document.getElementById("text1").focus();
</script>
</div>
</div>
</div>
</body>


DETAIL used EXTJS:
version:1.1.1 (rev 874)
adapter: ext-base.js
browser: IE6 and FF2

sorry for repost this message? ()
:-/

thank's

fay
8 Dec 2007, 2:24 AM
To focus a field I'd use:


var fld = myForm.findField(myFieldName);
if (fld)
fld.focus();

after the form has been rendered.

Btw, best not to use inline script like that, put your JS in the onReady().

hnd
9 Dec 2007, 9:26 PM
it's still not work...

the function inside onReady();
1. error message: "this property does not support this........"

the function inline and set as document.el.
2. error message: "Can't move focus.............."

i'd use with complex layout.

(:|help......

fay
10 Dec 2007, 5:09 AM
It's impossible to guess what's wrong without seeing more code. Post Main.init()