Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Help with toUpperCase or toLowerCase

Hi Everybody. I'm having some difficulties with the following.

I need to turn a value in a search bar and a value from a database to UpperCase or LowerCase. I'm doing the following:

var data_1 = search_bar.value;
var data_2 = myResultSet.fieldByName('name');

data_1.toUpperCase()
data_2.toUpperCase()

if (data_1 == data_2){ —> do something.

Titanium is giving me an error, saying that data_2 is not a string. How can I accomplish this?

I just want to turn both values into lower Case or UpperCase, so if the user types in any way, it can search the database and locate the result, no matter how is written.

Hope to hear from you guys. Thanks in advanced!!!

— asked November 15th 2010 by Pablo Rodriguez
  • android
  • case
  • database
  • iphone
  • lower
  • mobile
  • search
  • upper
  • values
0 Comments

5 Answers

  • Alright!!! I just solved it! I just needed to do this:

    data_1 = data_1.toUpperCase(); etc…

    Thanks Hal H for you help!

    — answered November 16th 2010 by Pablo Rodriguez
    permalink
    0 Comments
  • Hi Pablo, are you able to output the contents of both data_2 and myResultSet.fieldByName('name') using Ti.API.info()? Do they appear equal? Also try using typeof() to tell you their type. If I have understood you correctly, there is no need to use separate methods based on whether the user has typed their name in upper or lower case - simply choose one and always use that method for each.

    — answered November 15th 2010 by Paul Dowsett
    permalink
    0 Comments
  • Hi Hal H. Thanks for answering. Using Ti.API.info() returns data_1 and data_2 as the same as they were written. Meaning that the toUpperCase or toLowerCase is not working. Using typeof() returns that both variables are strings.

    I didn't understand the last sentence you wrote. Basically what I need is to both variable be UpperCase or LowerCase in order to both be exactly the same and compare if each other are equal (for example, the user types "flower", but in the database is written "Flower"; if both are in lowercase or uppercase, they will match).

    I don't know if this is the best way to achieve this or is there any other way to acomplish this?

    Thanks for helping me!

    — answered November 16th 2010 by Pablo Rodriguez
    permalink
    0 Comments
  • Hi Hal H. Thanks for answering. Using Ti.API.info() returns data_1 and data_2 as the same as they were written. Meaning that the toUpperCase or toLowerCase is not working. Using typeof() returns that both variables are strings.

    I didn't understand the last sentence you wrote. Basically what I need is to both variable be UpperCase or LowerCase in order to both be exactly the same and compare if each other are equal (for example, the user types "flower", but in the database is written "Flower"; if both are in lowercase or uppercase, they will match).

    I don't know if this is the best way to achieve this or is there any other way to acomplish this?

    Thanks for helping me!

    — answered November 16th 2010 by Pablo Rodriguez
    permalink
    0 Comments
  • Alright!!! I just solved it! I just needed to do this:

    data_1 = data_1.toUpperCase(); etc…

    Thanks Hal H for you help!

    — answered November 16th 2010 by Pablo Rodriguez
    permalink
    1 Comment
    • Great news Pablo! Well done! It's satisfying solving a problem on your own, which you did, isn't it? :)

      There is a chance that I have misunderstood you when you were talking about comparing the username with the database. Apologies for that.

      — commented November 16th 2010 by Paul Dowsett
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.