How to pass the hidden field's value within the context of iframe?

A

AwefulService

Hi,

I'm having some trouble with this issue, need some help.

WHAT I want
------------------
call another javascript to so something about the data within a
particular iframe upon a button click and stay on the same page.

What is working
-----------------------
Here's the basic code:

<script>
function init() {
frames.firstFrame.document.designMode = "On";

Editor = document.getElementById('text').contentWindow.document;

document.forms['frm'].onsubmit = function()

{
var data = document.getElementById('text');
data.value = Editor#currentrow#.body.innerHTML;
}

</script>

<html>
<body onload="init()">
<form id="frm">
<iframe id="text"></iframe>
<input type="hidden" name="data" id="data">
<input type="submit" value="Save" onclick="anotherJSfunction()">
</form>
</body>
</html>


What is NOT working
-----------------------
Here's the basic code:

<script>
function init() {
frames.firstFrame.document.designMode = "On";

Editor = document.getElementById('text').contentWindow.document;

document.forms['frm1'].onsubmit = function()

{
var data = document.getElementById('text');
data.value = Editor#currentrow#.body.innerHTML;
}

</script>

<html>
<body onload="init()">
<form id="frm">
<iframe id="text"></iframe>
<input type="hidden" name="data" id="data">
<input type="button" value="Save" onclick="anotherJSfunction()">
</form>
</body>
</html>

My rant:
So, what stumbled me is how to bind/tie the hidden field and its
without the SUBMIT type, how to overcome it?

Many thanks.
 
D

Don Li

Never mind. I've figured it out. But another related question
though.

Is there any way to use "SRCless" iframe?
For instance, <iframe id="frame1" value="Bla bla..."></iframe> instead
of
<iframe id="frame1" src="someFile.ext"></iframe>

When I pull data out of a db and generate multiple iframes I'd
naturally want to insert value into each iframe dynamically? What's a
good way for that?

Thanks.
 

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,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top