textarea and images

Discussion in 'JavaScript' started by gabs, Dec 14, 2006.

  1. #1
    Can anyone point me in the direction of a js script that insert a image into a text areas..

    I've been looking at all the text editor but want to build my own from the start..

    Thanks. .

    e.g.
    <textarea><img src=http://forums.digitalpoint.com/images/misc/dps_logo.gif></textarea>
    
    Code (markup):
     
    gabs, Dec 14, 2006 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    You mean like in WYSIWYG editors? They don't use Textareas. What you're trying to do is not possible.
     
    nico_swd, Dec 14, 2006 IP
  3. gabs

    gabs Peon

    Messages:
    135
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yep..

    Can you point my in the direction of a guidle or just a simple example?
     
    gabs, Dec 14, 2006 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    nico_swd, Dec 14, 2006 IP
  5. gabs

    gabs Peon

    Messages:
    135
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    been doing that already..

    I assume its a html insert into a div. .

    My example that doesn't work..

    Text is inserted but not the "html" ummm..

    Thanks btw

    <html>
           <script language="javascript">
                  // setup the main array
                  var setArray = Array("<img scr=http://www.google.co.uk/intl/en_uk/images/logo.gif>");
    
                  // insert the array into the DIV smalltest object
                  function insertArray()
                  {
                         var theText = ""; // set the theText output to an empty string otherwise it would start with null.
                         for (var i=0; i < setArray.length; i++)
                         {
                                // create the array of text to insert
                                theText += setArray[i];
                         }
                         // create the createTextNode 
                         var insertText = document.createTextNode(theText);
                         document.getElementById("smalltest").appendChild(insertText);
                  }
           </script>
           <body>
                  Just a small test, 
                  <div id="smalltest">
                  </div>
                  <input type="submit" value="click here" onclick="javascript:insertArray()" />
           </body>
    </html>
    Code (markup):
     
    gabs, Dec 14, 2006 IP
  6. weknowtheworld

    weknowtheworld Guest

    Messages:
    306
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I think rather you download the any html editor and lookout how they run...
     
    weknowtheworld, Dec 14, 2006 IP
  7. Krownet

    Krownet Peon

    Messages:
    42
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I found a great WYSIWYG tutorial once on PHPBuilder (I think that's where it was). Anyways, the one I found used iFrames to place the data. I dont think it was anything but IE compatible though =/

    TinyMCE is a great WYSIWYG editor, although a little on the large size, and takes quite a while to load.
     
    Krownet, Dec 14, 2006 IP