Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Display information from mysql database with only first letter uppercase

Posted on 2013-05-13
3
Medium Priority
?
289 Views
Last Modified: 2013-05-13
Hi all!

I am storing all my data in a mysql database putting it all uppercase (so I am sure about duplicates and I can do non case sensitive search.

Is this a good idea or there are better solutions?

Now the problem is that I am building a jQuery Mobile application and all the text is uppercase.
In php I'd use a couple of commands to make all the text lowercase and then with ucfirst I'd obtain from "TEST" a more pleasing "Test".

How can I do this dinamically in jQuery Mobile?
0
Comment
Question by:ltpitt
3 Comments
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39160682
if u want to have each word in the variable to be upper case then use the following:
var str = "hello world";
str = str.toLowerCase().replace(/\b[a-z]/g, function(letter) {
    return letter.toUpperCase();
});

Open in new window

result-->  Hello World



if u want just the 1st character then use the following:
var str = "hello world";
str = str.toLowerCase().charAt(0).toUpperCase() + string.slice(1);

Open in new window

result-->  Hello world
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 2000 total points
ID: 39162323
You could do it on the browser with just a css class:

.elem {text-transform:capitalize;} will set to lower case and the first letter of each word will be upper case

If you want just the first letter of a string to be upper case than

.elem {text-transform:lowercase;}
.elem:first-letter {text-transform:uppercase;}

Cd&
0
 
LVL 1

Author Closing Comment

by:ltpitt
ID: 39163132
Pure class (pun intended)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses
Course of the Month21 days, 1 hour left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question