By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,808 Members | 1,612 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,808 IT Pros & Developers. It's quick & easy.

posting content to an iframe

P: n/a
I have a page with a form as follows:

<form name="updfrm" method="post" action="update_db.cfm">
<input type="text" name="myfield" value="stuff">
<button onclick="sub_this();">press here</button>
</form>

normally I would either 1) let this form post to this window, or 2)
open a window and post to it.

I'd like to try posting that using an iframe.

So, I create that iframe in the same page as the form like:

<div style="display:none">
<iframe src="" id="update_iframe" name="update_iframe">
</iframe>
</div>

The script that takes the content from the form and updates the
database is called update_db.cfm.

So, my function looks like:

function sub_this()
{
var mycgi = "update_db.cfm";
document.getElementById('update_iframe').src=mycgi ;
document.updfrm.target = document.frames['update_iframe'];
document.updfrm.submit();
}

My browser IE6 does not like this at all. Its dieing and barfing.

Anyone see any problems here.

I have gotten this to work using get, but not post. Using get my
sub_this function would look like:

function sub_this()
{
var mycgi = "update_db.cfm?thecontent=" +
document.updfrm.elements['myfield'].value;
document.getElementById('update_iframe').src=mycgi ;
}

I don't really want to use get because I'd have to encode every
variable in the url. Some of them may be long.

Mike

Nov 10 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

mike wrote:
I have a page with a form as follows:

<form name="updfrm" method="post" action="update_db.cfm">
<input type="text" name="myfield" value="stuff">
<button onclick="sub_this();">press here</button>
</form>

normally I would either 1) let this form post to this window, or 2)
open a window and post to it.

I'd like to try posting that using an iframe.

So, I create that iframe in the same page as the form like:

<div style="display:none">
<iframe src="" id="update_iframe" name="update_iframe">
</iframe>
</div>

The script that takes the content from the form and updates the
database is called update_db.cfm.

So, my function looks like:

function sub_this()
{
var mycgi = "update_db.cfm";
document.getElementById('update_iframe').src=mycgi ;
document.updfrm.target = document.frames['update_iframe'];
document.updfrm.submit();
}


If the page with your form is already in the iframe, there is no need
to do a target. Just let the form submit and let it post back to the
same page.

Nov 10 '05 #2

P: n/a
Its not in the iframe ..... I plan on using the iframe for many things.

Nov 10 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.