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):
You mean like in WYSIWYG editors? They don't use Textareas. What you're trying to do is not possible.
I don't know exactly how they work either. But I'd suggest looking at the source code of an existnig WYSIWYG editor. There are quite a lot free ones available. http://www.google.com/search?hl=en&q=WYSIWYG+editor&btnG=Google+Search
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):
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.