JS Function to Insert Values Across Child Frames - Need Help

R

RoRNoob

I'd like the bar.html file to take the values contained in hidden
fields and stuff them into the form fields found on mymessagebox.html.
I can get it working no problem if it is all on the same page, but I'm
having trouble getting it to work across pages via the index.html
frames. Any help is appreciated.

code:

----- application.js -----

function inject_message() {
$('messagesubject').value = $F('hidden_subject');
$('messagebody').value = $F('hidden_body');
}

function clear_message() {
$('messagesubject').value = "";
$('messagebody').value = "";
}

----- index.html -----

<frameset rows="5%, 95%">
<frame src="bar/bar" name="bar">
<frame src="bar/mymessagebox" name="mymessagebox">
</frameset>

----- bar.html -----

<%= javascript_include_tag :defaults %> <!-- this loads application.js
-->

<a href='javascript:inject_message()'>inject me</a> | <a
href='javascript:clear_message()'>clear me</a>

<input type="hidden" id="hidden_subject" name="hidden_subject"
value="Hi there"/>
<input type="hidden" id="hidden_body" name="hidden_body" value="My
cool message"/>

----- mymessagebox.html -----

<div>

<div>
<p>Subject:</p>
<div>
<div>
<input type="text" style="width: 450px;" tabindex="1"
id="messagesubject" name="messagesubject"/>
</div>
</div>
</div>

<div>
<p>Body:</p>
<div>
<textarea style="width: 450px;" tabindex="2" id="messagebody"
cols="20" rows="20" name="messagebody"/>
</textarea>
</div>
</div>

</div>
 
V

venti

having trouble getting it to work across pages via the index.html

Whenever you need to save information (state) across pages, you may
find PHP Sessions of help. You can take form data, POST it to server,
and save the values as SESSION variables.
 
S

SAM

RoRNoob a écrit :
I'd like the bar.html file to take the values contained in hidden
fields and stuff them into the form fields found on mymessagebox.html.
I can get it working no problem if it is all on the same page, but I'm
having trouble getting it to work across pages via the index.html
frames. Any help is appreciated.

var f1 = parent.mymessagebox.document.forms[0];
var f2 = parent.bar.document.forms[0];

f2.messagesubject.value = f1.messagehydden.value;

or something like that (little lost in your code)
 
S

SAM

venti a écrit :
Whenever you need to save information (state) across pages, you may
find PHP Sessions of help. You can take form data, POST it to server,
and save the values as SESSION variables.

you can also in JS send variables attached to the url ...

But here it is only a question to send values from window to window (and
their documents) and no help from server is needed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,270
Latest member
TopCryptoTwitterChannels_

Latest Threads

Top