View Full Version : Setting the focus to field

05-19-2005, 03:59 PM
Hiya folks,
I have document which when loading sets the focus to a text box (the only one on the form) using the onload="MyTextBox.Focus()". After the user has entered some text here and pressed submit, an IFrame on the form is displayed.

The user then completes the data on the IFrame and presses the IFrame submit button. On clicking this Submit button I want to be able to set the focus back to the original text box on the 'parent' page. And I haven't got a clue as to how to achieve this.

Any offers??

Bill Posters
05-19-2005, 05:26 PM
…presses the IFrame submit button.…

On the iframe form mentioned above:

<form … onsubmit="parent.document.forms[0].inputElementId.focus();">

Change inputElementId to the id used on the original text input field on the parent page.

05-20-2005, 10:28 AM
Got round it by writing a little function on the main page and calling it from the submit or cancel button on the Iframe.

Thanks for the response.