what's the easiest way of line breaking overflowed text?

Discussion in 'PHP' started by monkeyclap, Feb 14, 2010.

  1. #1
    so that when i i have a blockquote width 500px, text without spaces does not keep on going and going on the same line...
     
    monkeyclap, Feb 14, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
  3. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You could use wordwrap() with <wbr> as the $cut parameter.
     
    SmallPotatoes, Feb 14, 2010 IP
  4. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #4
    is there a way to wrap according to width in pixels and not number of characters?
     
    monkeyclap, Feb 14, 2010 IP
  5. Will Bontrager

    Will Bontrager Peon

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Need font metrics to calculate line length.

    Barring that, I think you're stuck with estimating number of characters that will fit into the ideal width.

    Will
     
    Will Bontrager, Feb 14, 2010 IP
  6. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #6
    i think i should be using textareas instead of blockquotes, think that will fix it from the start. cheers
     
    monkeyclap, Feb 14, 2010 IP
  7. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #7
    update: yes it has, but i can't get select all onclick to work now :(
     
    monkeyclap, Feb 15, 2010 IP
  8. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #8
    danx10, Feb 15, 2010 IP
  9. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #9
    monkeyclap, Feb 15, 2010 IP
  10. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #10
    post the code your currently using here.

    although a link to the page would be more appropriate.
     
    danx10, Feb 15, 2010 IP
  11. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #11
    javascript in .js file, called in header:

    textarea i wish to select onclick:

     
    monkeyclap, Feb 15, 2010 IP
  12. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #12
    <SCRIPT type="text/javascript">
    function SelectAll(id)
    {
    document.getElementById(id).focus();
    document.getElementById(id).select();
    } 
    </SCRIPT>
    
    <textarea readonly cols="68" rows="10" id="txtarea" onClick="SelectAll('txtarea');">some text here</textarea>
    HTML:
    Works fine here...

    Are you sure your not modifying the code?, and that you have javascript enabled in your browser.
     
    danx10, Feb 15, 2010 IP
  13. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #13
    the only thing is the textarea is called using php if/else statements, but there are no errors there as it all loads fine
     
    monkeyclap, Feb 16, 2010 IP
  14. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #14
    Can you post that code then?
     
    danx10, Feb 16, 2010 IP
  15. Will Bontrager

    Will Bontrager Peon

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #15
    This might work for you.

    <textarea onclick="select()">content</textarea>
    Code (markup):
    Will
     
    Last edited: Feb 16, 2010
    Will Bontrager, Feb 16, 2010 IP
    monkeyclap likes this.
  16. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #16
    wow, that's incredible it works! any ideas why it didn't before? thanks again!
     
    monkeyclap, Feb 16, 2010 IP
  17. Will Bontrager

    Will Bontrager Peon

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #17
    No, no idea. Would need to see the source code of when it didn't work. Could speculate, but don't really want to take the time for that.

    Glad it's working.

    Will
     
    Will Bontrager, Feb 16, 2010 IP