Link to home
Start Free TrialLog in
Avatar of rickyr
rickyr

asked on

Forms in frames

Hiya........
A web page that has 3 frames, "top", "choose" and "show_info".
there is a form inside "choose" called "readad", this has a text box called N"AMESTART".
When I hit enter after putting a value in "NAMESTART"  it targets another frameset into show_info that has two frames "view" and "buttons".
At this stage (once view has loaded), I want to put the focus into NAMESTART (back up a couple of levels) and reset it, so that its empty.
Thanks
Avatar of knightEknight
knightEknight
Flag of United States of America image

First of all, rename your top frame to something besides "top" since this is an HTML keyword.  I suggest "topframe".

Then, in one of the files that goes into either the view frame or the buttons frame, do this:

<BODY onLoad='top.choose.document.readad.NAMESTART.value="";top.choose.document.readad.NAMESTART.focus();'>

.. BTW, I meant to say that "top" is a JavaScript keyword.
Avatar of rickyr
rickyr

ASKER

I tried this, (I have actually been trying this all along) but the focus doesn't get set, nor does it get reset.

I am doing this successfully for the same frame while a different form is in there.
heeeeeelp
In that case I would put the above code in the BODY tag of both the view frame and the buttons frame.  You might also want to put the whole thing in a setTimeout to give it an extra few milliseconds:

<BODY onLoad=setTimeout('top.choose.document.readad.NAMESTART.value="";top.choose.document.readad.NAMESTART.focus();',100)>


both this code, and the code above assume that your frame is named "choose", ie  <FRAME name="choose"

check also the name of your form and your textbox -- remember, these are all case-sensitive.
... could also be a simple HTML error, like a form within a form, or something wierd like that might cause this problem.
Avatar of rickyr

ASKER

Looks OK!
Could it be that I made a mistake about the levels in the frameset. Is there a way tp explicitly set it to the choose frame regardless of what frameset its nested in.
regards
Assuming that "choose" is one of your top level frames, then top.choose should work.  You could try parent.choose
Are you getting any error messages?  

Try this for debugging purposes:

<BODY onLoad='alert(self.name+" loaded");top.choose.document.readad.NAMESTART.value="";top.choose.document.readad.NAMESTART.focus();'>
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rickyr

ASKER

ta