Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

bbcode javascript html textarea

<script type="text/javascript"> 
<!-- 
    function formatText (tag) { 
        var selectedText = document.selection.createRange().text; 

        if (selectedText != "") { 
            var newText = "[" + tag + "]" + selectedText + "[/" + tag + "]"; 
            document.selection.createRange().text = newText; 
        } 
    } 
//--> 
</script> 

<form name="my_form"> 
    <textarea name="my_textarea"></textarea><br /> 
    <input type="button" value="bold" onclick="formatText ('b');" /> 
    <input type="button" value="italic" onclick="formatText ('i');" /> 
    <input type="button" value="underline" onclick="formatText ('u');" /> 
</form>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bbcode #javascript #html #textarea
ADD COMMENT
Topic
Name
4+7 =