arunpatal Posted October 27, 2013 Share Posted October 27, 2013 Hi, i can bold or underline the text which is inside textarea.... but how can i make like if i select some text and click on div button then the slected text will be inside a div. Also i want to have id for this div.... <html><head><script type="text/javascript" src="rich_textarea.js"></script></head><body onLoad="iFrameOn();"><h2>My web application that intakes data from users</h2><form action="my_parse_file.php" name="myform" id="myform" method="post"><div id="wysiwyg_cp" style="padding:8px; width:700px;"> <input type="button" onClick="iBold()" value="B"> <input type="button" onClick="iUnderline()" value="U"></div><textarea style="display:none;" name="myTextArea" id="myTextArea" cols="100" rows="14"></textarea><iframe name="richTextField" id="richTextField" style="border:#000000 1px solid; width:700px; height:300px;"></iframe><br /><br /><input name="myBtn" type="button" value="Submit Data" onClick="javascript:submit_form();"/></form></body></html> This is rich_textarea.js file function iFrameOn(){richTextField.document.designMode = 'On';}function iBold(){richTextField.document.execCommand('bold',false,null);}function iUnderline(){richTextField.document.execCommand('underline',false,null);}function submit_form(){var theForm = document.getElementById("myform");theForm.elements["myTextArea"].value = window.frames['richTextField'].document.body.innerHTML;theForm.submit();} Link to comment https://forums.phpfreaks.com/topic/283340-div-in-textarea/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.