HTML tags in Textarea

<form action=”” name=”myForm” method=”post”>
[&nbsp;<span class=”intLink” onclick=”insertMetachars(‘&lt;strong&gt;’,’&lt;\/strong&gt;’);”><strong>B</strong></span> | <span class=”intLink” onclick=”insertMetachars(‘&lt;em&gt;’,’&lt;\/em&gt;’);”><em>I</em></span> | <span class=”intLink” onclick=”var newURL=prompt(‘Enter the full URL for the link’);if(newURL){insertMetachars(‘&lt;a href=\u0022’+newURL+’\u0022&gt;’,’&lt;\/a&gt;’);}else{document.myForm.new_subspecify.focus();}”>URL</span>]<br>
<input type=”text” id=”doct_specialty” value=”” name=”new_subspecify”><br>
<input type=”submit” value=”Save” id=”butt_specialty” name=”hosp_services”>
function insertMetachars(sStartTag, sEndTag) {
var bDouble = arguments.length > 1, oMsgInput = document.myForm.new_subspecify, nSelStart = oMsgInput.selectionStart, nSelEnd = oMsgInput.selectionEnd, sOldText = oMsgInput.value;
oMsgInput.value = sOldText.substring(0, nSelStart) + (bDouble ? sStartTag + sOldText.substring(nSelStart, nSelEnd) + sEndTag : sStartTag) + sOldText.substring(nSelEnd);
oMsgInput.setSelectionRange(bDouble || nSelStart === nSelEnd ? nSelStart + sStartTag.length : nSelStart, (bDouble ? nSelEnd : nSelStart) + sStartTag.length);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s