Hi, I tried as you have mentioned. The script gets called, the element is obtained, but focus is not set.
<script> function setDefaultFocus() { alert("focusElm "+document.getElementById("newMedicine.newMedicineDEscription")); document.getElementById("newMedicine.newMedicineDEscription").focus(); } </script> I am calling it at the end of the JSP page using <script>setDefaultFocus()</script> I am unable to find out the reason for this. ----------------------------------- felipe.lorenz wrote: > > Ok. put it insede of tag <HEAD>. > > SOmething like this: > <head> > <script defer> > _your_javascript_here_ > </script> > </head> > > > On Wed, Jun 4, 2008 at 9:40 AM, StrutsUser <[EMAIL PROTECTED]> > wrote: > >> >> Hi, >> I tried this by putting this code in a javascript function and calling it >> during onfocus of <s:form>. It's not working. I am not sure how to call >> this >> function always when the page is loaded. >> >> Ajay >> >> >> felipe.lorenz wrote: >> > >> > Sure: >> > >> > document.getElementById(<id_of_element>).focus(); >> > >> > On Wed, Jun 4, 2008 at 8:40 AM, StrutsUser <[EMAIL PROTECTED]> >> > wrote: >> > >> >> >> >> Thanks Felipe. >> >> Could you give me some pointers in writing this sort of Javascript >> code >> >> for >> >> focussing on an element. >> >> I am not well versed in Javascript. That's why. >> >> Thanks & Regards >> >> Ajay >> >> >> >> >> >> felipe.lorenz wrote: >> >> > >> >> > I do this by java scritp... >> >> > >> >> > On Wed, Jun 4, 2008 at 8:12 AM, StrutsUser < >> [EMAIL PROTECTED]> >> >> > wrote: >> >> > >> >> >> >> >> >> Hi, >> >> >> I have a requirement where I need to set the focus in a particular >> >> >> element >> >> >> when a page is loaded. I tried using the 'focusElement' attribute >> in >> >> >> <s:form> tag. I got the error 'Attribute focusElement invalid for >> tag >> >> >> form >> >> >> according to TLD'. I am using struts2-core-2.0.11.jar and the form >> tag >> >> in >> >> >> this version does not have the 'focusElement' attribute. I tried >> >> >> downloading >> >> >> version 2.0.11.1 also. This too does not have this attribute. >> >> >> Could anyone please help me on how to get the latest struts2 jar. >> Or >> >> is >> >> >> there anyother way to set the focus to an element when the page is >> >> >> loaded? >> >> >> >> >> >> Thanks & Regards >> >> >> -- >> >> >> View this message in context: >> >> >> >> >> >> http://www.nabble.com/focusElement-attribute-in-%3Cs%3Aform%3E-tag-tp17644275p17644275.html >> >> >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> >> >> >> >> >> >> >> --------------------------------------------------------------------- >> >> >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >> >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> >> >> >> >> > >> >> > >> >> >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/focusElement-attribute-in-%3Cs%3Aform%3E-tag-tp17644275p17644692.html >> >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/focusElement-attribute-in-%3Cs%3Aform%3E-tag-tp17644275p17645786.html >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > -- View this message in context: http://www.nabble.com/focusElement-attribute-in-%3Cs%3Aform%3E-tag-tp17644275p17662672.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]