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 6 of 6
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    18
    Thanks
    1
    Thanked 1 Time in 1 Post

    Submit a textarea/iframe with wysiwyg-editor

    Hi! I am trying to use a very simpe wysiwyg-editor. It works fine, except i don't know how to proces the data from the iframe. I simply cant make use of the text written.
    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script type="text/javascript">
    function Init() {
    document.getElementById("rte").contentWindow.document.designMode = "On";
    }
    function doBold() {
    document.getElementById("rte").contentWindow.document.execCommand('bold', false, null);
    }
    function doItalic() {
    document.getElementById("rte").contentWindow.document.execCommand('italic', false, null);
    }
    function doURL() {
    var mylink = prompt("Enter a URL:", "http://");
       if ((mylink != null) && (mylink != "")) {
          document.getElementById('rte').contentWindow.document.execCommand("CreateLink",false,mylink);
       }
    }
    function doImage() {
    myimg = prompt('Enter Image URL:', 'http://');
    document.getElementById('rte').contentWindow.document.execCommand('InsertImage', false, myimg);
    }
    </script>
    </head>
    
    <body onLoad="Init();">
    
    <input type="submit" name="btnBold" value="bold" on id="btnBold" onClick="doBold();">
    <input type="submit" name="btnItalic" id="btnItalic" value="italic" onClick="doItalic();">
    <input type="submit" name="btnURL" id="btnURL" value="URL" onClick="doURL();">
    <input type="submit" name="btnImg" id="btnImg" value="Image" onClick="doImage();">
    <br>
    
    <form action="process.php" method="post">
    <iframe name="rte" id="rte"><textarea name="areal"></textarea>
    </iframe>
    <br>
    <input type="submit" value="Submit"></form>
    </body>
    </html>
    Most editors seem use this iframe-thing, without telling how to send the information by a form.
    Last edited by jorgenfi; 08-09-2009 at 08:01 PM. Reason: misspelling

  • #2
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    try adding a form in the iframe:

    Code:
    <iframe name="rte" id="rte"><form name='formane' action='actionname' method='post' target='_self'><textarea name="areal"></textarea>
    move the form from outside the iframe to inside the iframe.

    and let the submit button submit the inner form like this:

    Code:
    <input type="button" value="Submit" onclick='parent.rte.formname.submit()'></form>

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    18
    Thanks
    1
    Thanked 1 Time in 1 Post
    I tried that, but the submit-button doesn't appear.
    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script type="text/javascript">
    function Init() {
    document.getElementById("rte").contentWindow.document.designMode = "On";
    }
    function doBold() {
    document.getElementById("rte").contentWindow.document.execCommand('bold', false, null);
    }
    function doItalic() {
    document.getElementById("rte").contentWindow.document.execCommand('italic', false, null);
    }
    function doURL() {
    var mylink = prompt("Enter a URL:", "http://");
       if ((mylink != null) && (mylink != "")) {
          document.getElementById('rte').contentWindow.document.execCommand("CreateLink",false,mylink);
       }
    }
    function doImage() {
    myimg = prompt('Enter Image URL:', 'http://');
    document.getElementById('rte').contentWindow.document.execCommand('InsertImage', false, myimg);
    }
    </script>
    </head>
    
    <body onLoad="Init();">
    
    <input type="submit" name="btnBold" value="bold" on id="btnBold" onClick="doBold();">
    <input type="submit" name="btnItalic" id="btnItalic" value="italic" onClick="doItalic();">
    <input type="submit" name="btnURL" id="btnURL" value="URL" onClick="doURL();">
    <input type="submit" name="btnImg" id="btnImg" value="Image" onClick="doImage();">
    <br>
    
    <iframe height="300" width="300" name="rte" id="rte">
    <form target="_self" name="inside_form" action="behandle.php" method="post"><textarea rows="5" cols="40" name="test"></textarea>
    <input type="button" value="Submit" onclick='parent.rte.inside_form.submit()'></form></iframe>
    <br>
    
    </body>
    </html>

  • #4
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    you should move the submit button outside the iframe as well.
    So this:
    Code:
    <iframe height="300" width="300" name="rte" id="rte">
    <form target="_self" name="inside_form" action="behandle.php" method="post"><textarea rows="5" cols="40" name="test"></textarea>
    <input type="button" value="Submit" onclick='parent.rte.inside_form.submit()'></form></iframe>
    should be like this:
    Code:
    <iframe height="300" width="300" name="rte" id="rte">
    <form target="_self" name="inside_form" action="behandle.php" method="post"><textarea rows="5" cols="40" name="test"></textarea>
    </form></iframe>
    <input type="button" value="Submit" onclick='parent.rte.inside_form.submit()'>

  • #5
    New Coder
    Join Date
    May 2009
    Posts
    18
    Thanks
    1
    Thanked 1 Time in 1 Post
    Hm, I did what you told, but it still doens't work. Seems like anything written inside the iframe-tags isn't neither viewable nor working..

  • #6
    New Coder
    Join Date
    May 2009
    Posts
    18
    Thanks
    1
    Thanked 1 Time in 1 Post


  •  

    Posting Permissions

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