Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2003
    Location
    scotland, edinburgh
    Posts
    176
    Thanks
    5
    Thanked 1 Time in 1 Post

    link button bbcode

    ok just trying to get BBcode i think its called on my news admin script. As you all know it is uesed here for things like smiles and links. I have managed to get smilies working with this code which I found on the forums after a search

    Code:
    <script language="javascript">
    var obj;
    function insert(str){
    if (obj){
    obj.value+=str;
    obj.focus();
    }
    }
    </script>
    </head>
    <body>
    <form name="">
    <textarea name="t1" onfocus="obj=this"></textarea>
    <textarea name="t2" onfocus="obj=this"></textarea>
    
    <a href="javascript:insert(' :huh: ')"><img src="http://www.elitegnetwork.com/forums/html/emoticons/huh.gif" alt='smilie' border='0' /></a>
    
    </form>
    but what I didnt find while searching was the ability to have a link generation button where if u want to put in a link u press the button and a window pops up asking for the url and another for the url name

    I have made the php so that it finds these tags (blahname) and inserts the approprite html in so the result when posted is a real html link.
    So Now i am wanting to put in some javascript to help things become more user freindly

    So in short how do you make a add link button like the one above while writing in the forums?
    thanks

  • #2
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    Use the function and the example link below:
    Code:
    function url_prompt() {
        var url = window.prompt("Enter the URL of the link or nothing to cancel:", "http://");
        if(url) {
            var url_name = window.prompt("Enter the text to be displayed for the link (this is optional):", "");
            if(obj) {
                obj.value+= (url_name) ? "[ url="+url+"]"+url_name+"[/url]" : "[ url="+url+"]"+url+"[/url]";
                obj.focus();
            }
        }
    }
    
    <a href="javascript:url_prompt()">Add a link</a>
    Delete the white-spaces in the tags (this is only to prevent the forum from converting them.
    Last edited by dumpfi; 07-01-2004 at 12:31 AM.


  •  

    Posting Permissions

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