Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2013
    Location
    Finland/Estonia
    Posts
    51
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Using a function to set equal values to designMode iframe and a textbox

    Hello. I'm trying to take some text from a wysiwyg editor to a text field to submit it. However, the javascript function to do that seems to be messed up.
    This is my HTML:
    Code:
    <form action="../WYSIWYG/parse.php" name="myform" id="myform" method="post">
    <br /><textarea name="newPostPreview" class="noDisplay" cols="100" rows="10" /></textarea>
    <p>Preview for the Index Page:</p>
    <iframe name="richTextField_1" id="richTextField_1" class="fakeTextField"></iframe><br />
    <p>More text for the post page:</p>
    <br /><textarea name="newPost" class="noDisplay" cols="100" rows="10" id="newPost" /></textarea>
    <iframe name="richTextField" id="richTextField" class="fakeTextField"></iframe><br />
    <input type="submit" onclick="javascript:submit_form();" name="submit" value="Submit WYSIWYG"/>
    </form>
    This is the function:
    Code:
    function submit_form(){
    	var theForm = document.getElementById("myform");
    	theForm.elements["newPost"].value = window.frames["richTextField"].document.body.innerHTML;
    	var newPreview = theForm.elements["newPostPreview"].value = window.frames["richTextField_1"].document.body.innerHTML;
    	var newPost_textfield = theForm.elements["newPost"].value = window.frames["richTextField"].document.body.innerHTML;
    	theForm.submit();
    	_Redirect("../index.php");
    }
    I'm sure this is the part that's messing up because I set static values to the textareas and they passed.
    Last edited by estXcrew; 01-11-2014 at 03:45 PM. Reason: added <form> tags

  • #2
    New Coder
    Join Date
    Jul 2013
    Location
    Finland/Estonia
    Posts
    51
    Thanks
    9
    Thanked 0 Times in 0 Posts
    anyone?

  • #3
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,768
    Thanks
    55
    Thanked 518 Times in 515 Posts
    I don't know what that form.elements thing is supposed to be doing, but my error console doesn't like it. Try:
    Code:
    var theForm = document.getElementById("myform");
    theForm["newPost"].value = window.frames["richTextField"].document.body.innerHTML;
    theForm["newPostPreview"].value = window.frames["richTextField_1"].document.body.innerHTML;

  • #4
    New Coder
    Join Date
    Jul 2013
    Location
    Finland/Estonia
    Posts
    51
    Thanks
    9
    Thanked 0 Times in 0 Posts
    oops i left the form tags out of the html snippet..
    Edit: Didn't work.
    Edit2: Noone can help me?
    Last edited by estXcrew; 01-12-2014 at 09:48 AM.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,965
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Access the iframe body as:

    Code:
    window.frames["richTextField"].contentWindow.document.body


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •