/    Sign up×
Community /Pin to ProfileBookmark

POST and Iframe

I am trying to use the [URL=”http://www.mozilla.org/editor/midasdemo/”]Midas editor[/URL] from Mozilla, and one thing that is giving me hell is the textbox itself.

See, normally, the textbox has a “name” like everything in a regular form. So, once you write something in that textbox, you can easily pass the value to PHP like this:

[B]$content = $_POST[´textbox_name´];[/B]

Easy as pie. The problem is that the Midas text editor uses this:

[B]<iframe id=”edit” width=”100%” height=”200px”></iframe>[/B]

and whatever you type appears inside the iframe because the javascript has this:

[B]html = document.createTextNode(document.getElementById(‘edit’).contentWindow.document.body.innerHTML);
[/B]

I tried giving a name to the Iframe, but $_POST is not getting what I type inside the iframe.

Another thing I tried was putting the value of document.createTextNode(document.getElementById(‘edit’).contentWindow.document.body.innerHTML); inside the value of a hidden type in the form:

<input type=”hidden” value=”<script>document.write( html = document.createTextNode(document.getElementById(‘edit’).contentWindow.document.body.innerHTML); );</script>” />

But that doesn’t work either. Should I ask in the Javascript forum? Or someone knows what to do? I am thinking of finding another text editor, but I like Mozilla’s, even though it is a demo.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@MrCoderDec 05.2007 — Add a hidden field to your form with the name and id of "textdata".

<i>
</i>&lt;input type="hidden" name="textdata" id="textdata"&gt;


In you form onSubmit do this.
<i>
</i>&lt;form onSubmit="document.getElementById('textdata').value = document.getElementById('edit').contentWindow.document.body.innerHTML"&gt;
Copy linkTweet thisAlerts:
@rpcarnellauthorDec 05.2007 — That worked. Thanks
×

Success!

Help @rpcarnell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...