SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Threaded View

  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    removing "2" in the ending tag "[/size2]

    Code:
    <script type='text/javascript'>
    
    function ubbc(open, end){ 
        var tArea = document.myform.box; 
        var isIE = (document.all)? true : false; 
        var open = (open)? open : ""; 
        var end = (end)? end : ""; 
    
        if(isIE){ 
            tArea.focus(); 
            var curSelect = document.selection.createRange(); 
            if(arguments[2]){ 
                curSelect.text = open + arguments[2] + "]" + curSelect.text + end; 
            } else { 
                curSelect.text = open + curSelect.text + end; 
            } 
        } else if(!isIE && typeof tArea.selectionStart != "undefined"){ 
            var selStart = tArea.value.substr(0, tArea.selectionStart); 
            var selEnd = tArea.value.substr(tArea.selectionEnd, tArea.value.length); 
            var curSelection = tArea.value.replace(selStart, '').replace(selEnd, ''); 
            if(arguments[2]){ 
                tArea.value = selStart + open + arguments[2] + "]" + curSelection + end + selEnd; 
            } else { 
                tArea.value = selStart + open + curSelection + end + selEnd; 
            } 
        } else { 
            tArea.value += (arguments[2])? open + arguments[2] + "]" + end : open + end; 
        } 
    } 
    
    </script>
    
    <form name='myform' >
    
    <select onchange="ubbc('['+this.options[selectedIndex].value+']', '[/'+this.options[selectedIndex].value+']');this.selectedIndex=0;">
    <option value=noSize style=color:gray>size</option>
    <option value=size1>1</option>
    <option value=size2>2</option>
    </select>
    
    <textarea name='box' id='t1' style='width:300px;height:200px'>myText</textarea> 
    
    </form>
    I have the code above and its result at http://dot.kr/test/20.htm.

    If a user set a block to myText with his or her mouse and select 2 from the selection, The pseudo tag "[size2][/size2 ]" will generated around "myText."
    So it will be [size2]myText[/size2].



    Now I am telling you what I want.

    I like to generate "[size2]myText[/size]" instead of "[size2]myText[/size2]."
    Last edited by dotJoon; May 4, 2007 at 05:46.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •