Solved

Display information from mysql database with only first letter uppercase

Posted on 2013-05-13
3
262 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
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 …
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

864 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now