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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    California
    Posts
    511
    Thanks
    1
    Thanked 1 Time in 1 Post

    Need Help with BBCode

    Hey

    Ive been trying for days now to get a bbcode panel on my site for putting bbcodes and stuff into comment boxes since I have user inputted html striped from the comments, but so far ive had absolutely no luck. Ive tried several scripts but nothing seems to give any results. I just did a search on the Javascript forums here and tried a few of the 'working' scripts but they didnt work either. Here is the lastest one that i tried.

    Code:
    <html>
      <head>
        <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: ')">wee</a>
        </form>
      </body>
    </html>
    I have very little Js know how but Im aiming to learn, but this has me stumped...apparently it should work but it doesnt...could it be because im using FF...like i said, i dont know much about Js...if anyone can help me youd be saving me alot of frustration and I would greatly appreciate it, Ive got the php side of the bbcode script down, just the part where you click the link and the code is put into the text area is whats killing me =S
    When traveling down the road of life, Try not to drag your face in the gravel.

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Posts
    679
    Thanks
    0
    Thanked 16 Times in 15 Posts
    Not sure if this is what you are after
    Code:
    <html>
      <head>
        <script type="text/javascript">
        var obj;
        function insert(str){
        if (obj){
        document.getElementById(obj).value+=str;
        document.getElementById(obj).focus();
           }
        }
        </script>
      </head>
      <body>
        <form name="a1">
          <textarea name="t1" onfocus=obj='t1'></textarea>
          <textarea name="t2" onfocus=obj='t2'></textarea>
          
          <a href="javascript:insert(' :huh: ')">wee</a>
        </form>
      </body>
    </html>

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    California
    Posts
    511
    Thanks
    1
    Thanked 1 Time in 1 Post
    That code doesnt do anything either =S...does it work for you? is it a me thing lol?
    When traveling down the road of life, Try not to drag your face in the gravel.

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Posts
    679
    Thanks
    0
    Thanked 16 Times in 15 Posts
    Try it with id, I used IE and it didn't mind just the name
    Code:
    <html>
      <head>
        <script type="text/javascript">
        var obj;
        function insert(str){
        if (obj){
        document.getElementById(obj).value+=str;
        document.getElementById(obj).focus();
           }
        }
        </script>
      </head>
      <body>
        <form name="a1">
          <textarea name="t1" id="t1" onfocus=obj='t1'></textarea>
          <textarea name="t2" id="t2" onfocus=obj='t2'></textarea>
          
          <a href="javascript:insert(' :huh: ')">wee</a>
        </form>
      </body>
    </html>

  • #5
    Regular Coder
    Join Date
    Sep 2002
    Location
    California
    Posts
    511
    Thanks
    1
    Thanked 1 Time in 1 Post
    It still doesnt work with me I tried in both IE and Firefox....so very odd
    When traveling down the road of life, Try not to drag your face in the gravel.


  •  

    Posting Permissions

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