Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: on click add text at I beam in a input filed

  1. #1
    zeroradius's Avatar
    zeroradius is offline Speaks fluent binary
    Join Date
    Feb 2008
    Location
    Ohio
    Posts
    1,403
    Rep Power
    25

    on click add text at I beam in a input filed

    Hey guys, I am working on BB code for my site. When a user clicks a button I need it to add bb code to the text box at the I beam, or if a section of text is highlighted wrap the text in the tags (basicly I want it to work like every other forum on the net). Every time I google this it says it can't be done.

    Can anyone tell me how to achive this, maybe I am trying to use the wrong language?

    Note: My site uses PHP & MySQL so if I have to use another language I need it to work well with it.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    Re: on click add text at I beam in a input filed

    I can't think of the opposite to append but that's what you want to do. When the user clicks on the button, you want to find the text in the text field and append the bbcode to it. As for the highlighting I'm not to sure sorry but I did find this link that should help you a bit;
    Neowin Forums > [JavaScript] Appending text to an HTML Textbox

    EDIT:
    Another handy link;
    Java Script Tutorial - innerHTML
    jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
    Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!

  4. #3
    zeroradius's Avatar
    zeroradius is offline Speaks fluent binary
    Join Date
    Feb 2008
    Location
    Ohio
    Posts
    1,403
    Rep Power
    25

    Re: on click add text at I beam in a input filed

    So I parse the data at the spot where the I beam is then add in the bb code and concantinate it back together? hmmmm , I need to figure out how to break it apart then. The only parsing i have done is in php with explode() which would not work here. I am going to look into it in JS and check out those links. Thanks Brandon. I will probably be posting back here thou, I have never done JS other than popups -_-

    Oh and how does JS know were the I beam is?

  5. #4
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    Re: on click add text at I beam in a input filed

    Yes, that should work. Ummm I believe that JS would offer something like that but I haven't really done much JS.

    It's all good, I will continue to Google till I find the answer you are looking for unless someone that knows posts. I did a search on that but I can't think of the name for the beam you are talking about. I tried i-beam, beam, text beam... Can't think of anything else.
    jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
    Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!

  6. #5
    zeroradius's Avatar
    zeroradius is offline Speaks fluent binary
    Join Date
    Feb 2008
    Location
    Ohio
    Posts
    1,403
    Rep Power
    25

    Re: on click add text at I beam in a input filed

    Thanks brandon. It is called an I beam or a carrot. I have been yahooing it and can'tfind anything relevent eaither. I also checked the JS bible but it din't have it in there. The closest thing i found was somthing in IE that keeps track of the position but it would not work for any other browsers, I'm trying to make it work in IE,FF,and chrome

  7. #6
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    Re: on click add text at I beam in a input filed

    Only 4 comments on this script but from the looks of it, it should work;
    JavaScript: Caret Index - ZeroSleep

    This one doesn't look like it would work in IE according to the comments;
    Vishal Monpara’s Blog Javascript : Getting and Setting Caret Position in Textarea
    jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
    Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!

  8. #7
    zeroradius's Avatar
    zeroradius is offline Speaks fluent binary
    Join Date
    Feb 2008
    Location
    Ohio
    Posts
    1,403
    Rep Power
    25

    Re: on click add text at I beam in a input filed

    I checked out the example on the seconed one and it worked in IE , FF, and chrome. now that I have that I can figure out the rest of the code myself (i hope) Thanks a million. +Rep

  9. #8
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: on click add text at I beam in a input filed

    cursor is the technical name for the I-beam. Googling "javascript insert text at cursor" produced some promising results.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  10. #9
    zeroradius's Avatar
    zeroradius is offline Speaks fluent binary
    Join Date
    Feb 2008
    Location
    Ohio
    Posts
    1,403
    Rep Power
    25

    Re: on click add text at I beam in a input filed

    hmm, I could not find anything that made scence to me there WP. I thought maybe using that thing Brandon showed me with InsertAt() but that is a diffrent filetype wich means no .php

    So I decided to cheat. I set up a yabb forum and I took there code that does what i am wanting to do. I am about to print it out and study it to see how it works.

    Thanks Guys ^_^


    Edit: bah to much code not enouph coments nor enouph meaningful veriable names, I fail

    edit2: Haza. I can use a split like in this code

    Code:
    <script type="text/javascript">
    var myString = "123456789";
    
    var mySplitResult = myString.split("5");
    
    document.write("The first element is " + mySplitResult[0]); 
    document.write("<br /> The second element is  " + mySplitResult[1]); 
    </script>
    replace the value 5 with the number returned from the example in the secondlink of that post brandon made. that should work. Wont be able to test until tommorow cause I can't concentrate right now. but still it should work ^_^
    Last edited by zeroradius; 07-19-2009 at 12:23 PM.

  11. #10
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    Re: on click add text at I beam in a input filed

    Quote Originally Posted by zeroradius View Post
    I checked out the example on the seconed one and it worked in IE , FF, and chrome. now that I have that I can figure out the rest of the code myself (i hope) Thanks a million. +Rep
    Welcome.

    Quote Originally Posted by WingedPanther View Post
    cursor is the technical name for the I-beam. Googling "javascript insert text at cursor" produced some promising results.
    I was thinking of typing that in but I thought it might of come up with the position of the mouse cursor on the screen.

    Quote Originally Posted by zeroradius View Post
    hmm, I could not find anything that made scence to me there WP. I thought maybe using that thing Brandon showed me with InsertAt() but that is a diffrent filetype wich means no .php

    So I decided to cheat. I set up a yabb forum and I took there code that does what i am wanting to do. I am about to print it out and study it to see how it works.

    Thanks Guys ^_^


    Edit: bah to much code not enouph coments nor enouph meaningful veriable names, I fail

    edit2: Haza. I can use a split like in this code

    Code:
    <script type="text/javascript">
    var myString = "123456789";
    
    var mySplitResult = myString.split("5");
    
    document.write("The first element is " + mySplitResult[0]); 
    document.write("<br /> The second element is  " + mySplitResult[1]); 
    </script>
    replace the value 5 with the number returned from the example in the secondlink of that post brandon made. that should work. Wont be able to test until tommorow cause I can't concentrate right now. but still it should work ^_^
    Tell us how it goes, I don't know if that would be very efficient.
    jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
    Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to Take a Text as an Input
    By Beeko in forum Java Help
    Replies: 23
    Last Post: 06-19-2011, 11:56 AM
  2. input name for text file (.txt)
    By Amonijack in forum C and C++
    Replies: 1
    Last Post: 06-17-2011, 03:36 AM
  3. Input Text(For Beginners)
    By michaelvd12 in forum C Tutorials
    Replies: 4
    Last Post: 07-27-2009, 01:54 AM
  4. Input Text (for beginners)
    By michaelvd12 in forum C Tutorials
    Replies: 0
    Last Post: 04-24-2009, 12:48 PM
  5. detecting value in input text box
    By janu in forum Visual Basic Programming
    Replies: 2
    Last Post: 04-02-2009, 02:17 AM

Tags for this Thread

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