ASP Trim Text String

Out of context: Reply #2

  • Started
  • Last post
  • 9 Responses
  • nonakedflame0

    function trimDescription(p_String, p_Length) {

    /*
    if it the length is greater then the no of words in the article, return the string
    */

    if (p_Length > p_String.length) {
    return p_String;
    }

    /*
    Split the string up on the spaces
    */

    splitString = p_String.split(" ");

    var trimmedString = "";

    for (a=0; a < p_Length; a++) {

    trimmedString += " " + splitString[a];

    }

    return trimmedString;

    }

    Usage -

    Top of page ---

    In table cell

    note : this is a very cheap & nasty way of doing this... does not account for leading and/or trailing spaces...

    Hope this helps (works for me!)

View thread