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.
Page 1 of 3 123 LastLast
Results 1 to 15 of 31
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post

    [b][/b], [quote][/quote] how?

    I use Firefox and am wondering how to select a word and wrap [b] tags or [quote] tags around it? Any tutorials?
    Compare bible texts (and other tools):
    TheWheelofGod

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,931
    Thanks
    79
    Thanked 4,423 Times in 4,388 Posts
    Select where? Anyplace on the page? Or only in a form field?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Old Pedant View Post
    Select where? Anyplace on the page? Or only in a form field?
    in the textarea of course just like this reply I'm typing in.
    Compare bible texts (and other tools):
    TheWheelofGod

  • #4
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by gilgalbiblewhee
    I use Firefox and am wondering how to select a word and wrap [b] tags or [q uote] tags around it? Any tutorials?
    Check out this LINK (hint: look at the page source).

    I got bored, so I made up a demo for you. Everything you need you can dig out of the one file. Do a "view source", then copy and paste it to your editor.

    -- Roger
    Last edited by Krupski; 12-28-2010 at 04:27 AM.

  • #5
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Goodish code Krupski but it has many bugs such as if you click any of the buttons after you fill the text area more than 1-2 times it messes up.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #6
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by DJCMBear View Post
    Goodish code Krupski but it has many bugs such as if you click any of the buttons after you fill the text area more than 1-2 times it messes up.
    It's just a demo. The core code he needs is right there.

    Oh and I fixed the bug... "overflow:auto". LOL!

  • #7
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Nooo I mean if you put a bold tag inside a bold tag it messed up, what happens if you quote someone's quote like people do on here it wouldn't work as it doesn't allow you to have the same code inside itself.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #8
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Krupski View Post
    Check out this LINK (hint: look at the page source).

    I got bored, so I made up a demo for you. Everything you need you can dig out of the one file. Do a "view source", then copy and paste it to your editor.

    -- Roger
    Ok Thanks.
    Compare bible texts (and other tools):
    TheWheelofGod

  • #9
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by DJCMBear View Post
    Nooo I mean if you put a bold tag inside a bold tag it messed up, what happens if you quote someone's quote like people do on here it wouldn't work as it doesn't allow you to have the same code inside itself.
    Oh I know. Originally I was just going to show how to insert stuff, then I decided to play with replacing the tags with HTML. I shouldn't have put in text replace stuff anyway... but I was bored!

    Anyway, it's out now. Now it's just a demo of what the OP originally wanted.

    -- Roger

  • #10
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by gilgalbiblewhee View Post
    Ok Thanks.
    Did it help you out?

  • #11
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Lol nah I just thought I should tell you if you didn't know about it so you could fix it.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #12
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Krupski View Post
    Did it help you out?
    I'm still adjusting it to my codes. Why did you put the onload? Wouldn't it work to define it in the JS code?

    Ok it works so far but why do the gif images look off?
    Last edited by gilgalbiblewhee; 12-28-2010 at 08:15 AM.
    Compare bible texts (and other tools):
    TheWheelofGod

  • #13
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    
    
    
    <script type="text/javascript">
    
    //http://www.codingforums.com/showthread.php?t=134113 - Author Kor
    
    
    function formatText(el,tag){
    var selectedText = document.selection?document.selection.createRange().text:el.value.substring(el.selectionStart,el.selectionEnd);// IE:Moz
    if (selectedText == "") {return false}
    var newText='<'+tag+'>'+selectedText+'</'+tag+'>';
    if(document.selection){    //IE
    document.selection.createRange().text=newText;
    }
    else{   //Moz
    el.value=el.value.substring(0,el.selectionStart)+newText+el.value.substring(el.selectionEnd,el.value.length);
    }
    }
    </script>
    </head>
    
    <body>
    <form name="myForm">
    <textarea name="myTextarea" style="font-family:arial; font-size = 12pt" rows = "12" cols = "50">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</textarea><br>
    
    <input type="button" value="Bold" onclick="formatText (myTextarea,'b');" />
    <input type="button" value="Italic" onclick="formatText (myTextarea,'i');" />
    <input type="button" value="Underline" onclick="formatText (myTextarea,'u');" />
    </form>
    
    
    This works with all browsers.  Author Kor.
    </body>
    </html>
    "Insanity is doing the same thing over and over again, but expecting different results." - Rita Mae Brown

  • #14
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by Philip M View Post
    Code:
    //http://www.codingforums.com/showthread.php?t=134113 - Author Kor
    The code you posted is functionally almost identical to what I posted.

    Only differences I see are:

    (1) Mine will insert the tags even with no selection (so that a user can insert his/her own text later).

    (2) I added "live view" to the demo (btw gilgalbiblewhee that's what the onload was for - to kick-start the live view updater - you don't need that for your application).

    Or am I missing something?

    -- Roger

  • #15
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by Krupski View Post
    The code you posted is functionally almost identical to what I posted.
    Or am I missing something?

    -- Roger
    Well, mine works. And it gives the OP a choice. As we often say, there is more than one way to kill a cat!
    Last edited by Philip M; 12-28-2010 at 03:46 PM.


  •  
    Page 1 of 3 123 LastLast

    Posting Permissions

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