SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry deploy bbcode at cursor

    Hello guys I'm kinda new to php and I'm working on a site and I can't seem to get the smileys to deploy at the cursor in stead of the end of the text.

    I'm getting really fedup allways cutting and pasting to where I want to put the.


    I've been over a dosen forums for this with no luck yet.
    I hope someone here can help me.

    I'm really still a noob in this

  2. #2
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The javascript code you to use for full BB codes is:
    Just modify it to do just smilies.
    PHP Code:
    <div style="text-align:center;">
    <
    a href="javascript:element('bold')"><b>Bold</b></a>&nbsp; &nbsp; &nbsp;
    <
    a href="javascript:element('italics')"><i>Italics</i></a> &nbsp; &nbsp; &nbsp;
    <
    a href="javascript:element('underline')"><u>Underline</u></a> &nbsp; &nbsp; &nbsp;
    <
    a href="javascript:element('strike')"><s>Strike</s></a> &nbsp; &nbsp; &nbsp;
    <
    a href="javascript:element('link')">Link</a><br/>
    <
    a href="javascript:element('pre')">Pre</a></div> <br/>

    <
    script type="text/javascript">
      
    function 
    element(decoration){
    var 
    stayput document.getElementById('content').scrollTop;
    var 
    str1  = (document.getElementById("content").value).substring(0document.getElementById("content").selectionStart);
    var 
    str2  = (document.getElementById("content").value).substring(document.getElementById("content").selectionStartdocument.getElementById("content").selectionEnd);
    var 
    str3  = (document.getElementById("content").value).substringdocument.getElementById("content").selectionEnd);
    if (
    decoration == "bold"){str2 "[b]" str2 "[/b]";}
    else if(
    decoration == "italics"){ str2 '[i]' str2 '[/i]';}
    else if(
    decoration == "underline"){   str2 '[u]' str2 "[/u]";}
    else if(
    decoration == "strike"){ str2 '[s]' str2 '[/s]';}
    else if(
    decoration == "pre"){ str2 '[pre]' str2 '[/pre]';}
    else if(
    decoration == "link"){ str2 "[a href=\"" str2 "\"];"str2 "[/a]";}

    document.getElementById("content").value str1 str2 str3;
    document.getElementById('content').scrollTopstayput;
    }
    </script> 

  3. #3
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    function PopMoreTags(form,name) {
             
    link='moretags.php?form='+form+'&text='+name
             newWin
    =window.open(link,'moresmile','height=500,width=775,resizable=no,scrollbars=yes');
             if (
    window.focus) {newWin.focus()}
    }


    function 
    BBTag(tag,s,text,form){
    switch(
    tag)
        {
        case 
    '[quote]':
        if (
    document.forms[form].elements[s].value=="QUOTE ")
           {
            
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[quote]";
            
    document.forms[form].elements[s].value="QUOTE*";
            }
           else
               {
               
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[/quote]";
               
    document.forms[form].elements[s].value="QUOTE ";
               }
            break;
        case 
    '[img]':
        if (
    document.forms[form].elements[s].value=="IMG ")
           {
            
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[img]";
            
    document.forms[form].elements[s].value="IMG*";
            }
           else
               {
               
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[/img]";
               
    document.forms[form].elements[s].value="IMG ";
               }
            break;
        case 
    '[url]':
        if (
    document.forms[form].elements[s].value=="URL ")
           {
            
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[url]";
            
    document.forms[form].elements[s].value="URL*";
            }
           else
               {
               
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[/url]";
               
    document.forms[form].elements[s].value="URL ";
               }
            break;
        case 
    '[*]':
        if (
    document.forms[form].elements[s].value=="List ")
           {
            
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[*]";
            }
            break;
        case 
    '[b]':
        if (
    document.forms[form].elements[s].value=="B ")
           {
            
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[b]";
            
    document.forms[form].elements[s].value="B*";
            }
           else
               {
               
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[/b]";
               
    document.forms[form].elements[s].value="B ";
               }
            break;
        case 
    '[i]':
        if (
    document.forms[form].elements[s].value=="I ")
           {
            
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[i]";
            
    document.forms[form].elements[s].value="I*";
            }
           else
               {
               
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[/i]";
               
    document.forms[form].elements[s].value="I ";
               }
            break;
        case 
    '[u]':
        if (
    document.forms[form].elements[s].value=="U ")
           {
            
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[u]";
            
    document.forms[form].elements[s].value="U*";
            }
           else
               {
               
    document.forms[form].elements[text].value document.forms[form].elements[text].value+"[/u]";
               
    document.forms[form].elements[s].value="U ";
               }
            break;
        }
        
    document.forms[form].elements[text].focus();
    }

    </script> 
    how would I change that if this is my bbcode?


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
  •