Chaning Text Field Color if ClientID exists in DB

0 views
Skip to first unread message

Dev Sherpa

unread,
Aug 25, 2010, 6:01:40 AM8/25/10
to professi...@googlegroups.com
Hi All,

I have a text field named 'clientid' in my app where user will enter client id.

As soon user left this field (onblur), I want to check whether the entered client id exists in database or not.

If client id exists, border of text field named 'clientid' should be changed to green else it should be changed to red.

I know how to fetch the record from database i.e.

// Connecting to MySQL Server
$cn = mysql_connect(DBHOST, DBUSER, DBPASS);
if(!$cn) { die(mysql_errno($cn) . ": " . mysql_error($cn)); }

// Selecting MySQL Database
$db = mysql_select_db(DBNAME, $cn);
if(!$db) { die(mysql_errno($cn) . ": " . mysql_error($cn)); }

// Preparing MySQL Query
$query = "SELECT * FROM CLIENT WHERE clientid = '" . mysql_real_escape_string($clientid) . "'";

// Executing MySQL Query
$rs = mysql_query($query,$cn);
if(!$rs) { die(mysql_errno($cn) . ": " . mysql_error($cn)); }

if(mysql_num_rows($rs)>=1) { $ROW = mysql_fetch_assoc($rs); }

// Freeing up memory by unset variables, connection resource, and resultset
mysql_free_result($rs);
mysql_close($cn);
unset($cn,$db,$query,$rs);

But I do not know how to check color of text field border upon blur after checking clientid in database.

Please help me to resolve this problem.

Regards
Dev Sherpa

Robert Gonzalez

unread,
Aug 30, 2010, 1:34:07 AM8/30/10
to professi...@googlegroups.com
Download jQuery. Read it's docs about using Ajax, CSS and selectors.
Have fun watching colors change all over the place.

> --
> This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.
>
> For information or project assistance please visit :
> http://www.360psg.com
>
> You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
> To post to this group, send email to Professi...@googlegroups.com
> To unsubscribe from this group, send email to Professional-P...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/Professional-PHP

Dev Sherpa

unread,
Sep 1, 2010, 3:32:53 PM9/1/10
to professi...@googlegroups.com
Thanks Robert.

I Never thought that this is so easy to get it done with Jquery. I have done it.

Regards
Dev Sherpa

Robert Gonzalez

unread,
Sep 1, 2010, 4:15:57 PM9/1/10
to professi...@googlegroups.com
Dude, just wait. There are so many things about jQuery that will blow your mind.

Joe Williams

unread,
Sep 1, 2010, 4:28:18 PM9/1/10
to professi...@googlegroups.com
And remember in Russia jQuery codes for you!!!

-------
Twitter: @mrstatic
Website: https://www.speakservers.com

Sent on the Sprint® Now Network from my BlackBerry®


From: Robert Gonzalez <robert.anth...@gmail.com>
Date: Wed, 1 Sep 2010 13:15:57 -0700
Subject: Re: [Pro. PHP Dev.] Chaning Text Field Color if ClientID exists in DB

David Mans

unread,
Sep 1, 2010, 4:29:27 PM9/1/10
to professi...@googlegroups.com
Such an understatement.

Jack Timmons

unread,
Sep 2, 2010, 6:50:52 AM9/2/10
to professi...@googlegroups.com
On Wed, Sep 1, 2010 at 3:28 PM, Joe Williams
<joseph.s...@gmail.com> wrote:
> And remember in Russia jQuery codes for you!!!

It does that wherever you are.


--
Jack Timmons
@_Codeacula

Reply all
Reply to author
Forward
0 new messages