Solved

Display information from mysql database with only first letter uppercase

Posted on 2013-05-13
3
258 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
Comment Utility
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
Comment Utility
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
Comment Utility
Pure class (pun intended)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

762 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

15 Experts available now in Live!

Get 1:1 Help Now