Solved

Display information from mysql database with only first letter uppercase

Posted on 2013-05-13
3
265 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:sedgwick
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 500 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

785 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