Link to home
Start Free TrialLog in
Avatar of arwebs
arwebs

asked on

Accessing controls in one frame from another

I have a frameset with 2 frames:

<frameset rows="20%,*">
<frame src="Toolbar.htm" name="tbar">
<frame src="Input.htm" name="main">
</frameset>

The page 'Input.htm' contains a textarea control (id=txtName).

The page 'Toolbar.htm' contains a number of buttons.

When I click one of these buttons, I want to modify the text in txtName. How do I do it?

I know this would be easier if I had the buttons on the same page as the textarea, but I need to do it this way.

Thanks in advance for your replies.
Avatar of arwebs
arwebs

ASKER

Edited text of question.
If you gave your form the name "myForm" the correct reference to the input name="txtName" from the document in frame name="tbar" would be:

parent.main.document.myForm.txtName

So to change it's value you just set its value property from some function or expression, e.g.

<INPUT TYPE="button" VALUE="Set text to 'hello'" onClick="parent.main.document.myForm.txtName='hello'">
input.htm must have something like

<form name="myform">
<textarea name="txtName"></textarea>
</form>

then toolbar.htm has this :

<form name="myform2">
<input type="button" value="Put string" onClick="parent.main.document.myform.txtName.value='the string'">
</form>

Joseph
Are you having a joke with me Joseph?
hehe...just added the .value....because this what it must be, not? Hey, don't worry my man, you may have the points if arwebs thinks your solution works..
Yup, forgot to add .value (bugger). Er... at least I refered to it, if not in the code itself (desperate backsliding).

What you should have posted was something like michel would with another half a dozen references to why my code will not in the Bolivian localisied version of MSIE 3.14a. Then I couldn't respond.
Ha! But I'm not Michel. ;|
ASKER CERTIFIED SOLUTION
Avatar of tripat
tripat

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
I see tripat, you're a newbie so,
mmm, please, answers like these should be posted as comments, not as answers. It's not fair to garrethg or me since we were here with some solutions which can help arwebs out. Your answer doesn't give any help to this question because the target isn't necessary to set here with this problem. In future please just give comments instead of answer like these.

Joseph