www.webdeveloper.com
Results 1 to 5 of 5

Thread: textTransform doesn't, not really

  1. #1
    Join Date
    Oct 2003
    Posts
    3

    textTransform doesn't, not really

    // Hi! first post here. I searched 'textTransform' and didn't get any results, so here's the new post

    A'ight - I have successfully transformed text
    document.getElementById(tgt.id).style.textTransfor m="capitalize";
    as part of a function triggered by an onblur event
    onblur="checkcase(this)"
    This changes the value of an input box from lower to Sentence case
    jason => Jason
    But it's not really changed... It just looks like it's changed.
    By that I mean:
    1) the client-side javascript function will continue to read 'jason' rather than 'Jason' even after the transform (confirmed with an alert box for the value)
    2) the server-side PhP email to which the form sends data (by way of a submit button) sends 'jason' rather than 'Jason'.

    Seriously... is it supposed to be like this? Why would it be like this? And at the very least... how can I transformText for reals*?

    Jason
    * for reals = so my js and PhP see the 'Jason' not 'jason'

  2. #2
    Join Date
    Aug 2007
    Posts
    3,767
    Yes, it's supposed to be like that. It's a CSS Property.

    JavaScript can use regular expressions and replace to actually change it.
    Code:
    tgt.value = tgt.value.replace(/(^|\s+)(\w)/g,function(m){
    return m.toUpperCase();};
    That presumes that tgt is a reference to the element, as it seems to be. In other words, I presume the function looks like
    Code:
    function checkcase (tgt) {
    // code
    }
    Great wit and madness are near allied, and fine a line their bounds divide.

  3. #3
    Join Date
    Oct 2003
    Posts
    3

    texts

    Turns out a ucwords(strtolowercase(txt)) in PhP is the best option.

    I'll just assume the user is going to enter it incorrectly and hope there are no DeKalbs or McGonegals...

  4. #4
    Join Date
    Oct 2003
    Posts
    3
    and thanks for the reply. that does explain it, but it doesn't do what I want...

  5. #5
    Join Date
    Aug 2007
    Posts
    3,767
    Quote Originally Posted by dday76 View Post
    Turns out a ucwords(strtolowercase(txt)) in PhP is the best option.
    PHP is the best place to do this, definetly.
    Great wit and madness are near allied, and fine a line their bounds divide.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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



Recent Articles