WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Hilight Form Element onFocus
Categories : Java Script, Form Processing, CSS Click here to Update Your Picture
Joyce Babu
Date : Jul 02nd 2006
Grade : 2 of 5 (graded 1 times)
Viewed : 8244
File : 4438.zip
Images : Image 1 , Image 2
Search : More code by Joyce Babu
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

This script can be used to hightlight a form element on recieving focus and remove it on losing focus.

hilite.js
var hiliteClass = 'hilightedInputField';
var normalClass = 'inputField';
var hilitedElem = '';
var regExp = /INPUT|OPTION|SELECT|TEXTAREA/;

var ns6=document.getElementById && !document.all

//Function to highlight form element
function hilite(evt){
    evt = evt ? evt : window.event;
    var currentElem = evt.srcElement ? evt.srcElement : evt.target || evt.currentTarget;
    if(currentElem.className && regExp.test(currentElem.tagName)){
        //if (ns6&&eventobj.nodeType==3)eventobj=eventobj.parentNode.parentNode
        if(hilitedElem)hilitedElem.className = normalClass;
        currentElem.className = hiliteClass;
        hilitedElem = currentElem;
    }
}
function removeHilite(evt){
    evt = evt ? evt : window.event;
    var currentElem = evt.srcElement ? evt.srcElement : evt.target || evt.currentTarget;
    if(currentElem.className && regExp.test(currentElem.tagName)){
        currentElem.className = normalClass;
    }
}



Usage Example (notice the attached images)
<!doctype html public "-//w3c//dtd html 4.1 transitional//en">
<html>
<head>
<title>Highlight Form Elements</title>
<meta name="Keywords" content="">
<meta name="Description" content="">
<meta name="MSSmarttagsPreventParsing" content="TRUE" />
<meta name="robots" content="index,follow" />
<script type="text/javascript" src="hilite.js"></script>
<style>
body, table{font:normal 12px Verdana, Arial, sans-serif;}
.tblTest td{background:#F4F4F9;border:1px #C0C0C0 solid;padding:5px 15px;}
.tblTest td span.comment{color:#999999;font-size:10px;font-style:italic;}
.inputField{width:240px;border:1px #C0C0C0 solid;}
.hilightedInputField{width:240px;background:#F9F9FF;border:1px #333333 solid;}
</style>
</head>

<body bgcolor="#ffffff">
<table style="height:100%;width:100%;">
<tr><td>

<center><form name="frmTest">
<table class="tblTest" cellspacing="2" cellpadding="0" style="">
<tr><td colspan="2" style=""><b>Highlight Form Elements</b></td></tr>
<tr><td>Text Box</td><td><input class="inputField" onfocus="hilite(event)" onBlur="removeHilite(event)" type="text"></td></tr>
<tr><td>Text Box</td><td><input class="inputField" onfocus="hilite(event)" onBlur="removeHilite(event)" type="text"></td></tr>
<tr><td>Text Area</td><td><textarea class="inputField" onfocus="hilite(event)" onBlur="removeHilite(event)" ></textarea></td></tr>
<tr><td>Text Area</td><td><textarea class="inputField" onfocus="hilite(event)" onBlur="removeHilite(event)" ></textarea></td></tr>
</table></form>
</center>
</td></tr></table>
</body>
</html>



Changing the Style of form objects using the JavaScript OnClick method.
Categories : Java Script, Form Processing, Beginner Guides, CSS
Javascript URL and Email Validation
Categories : Java Script, Data Validation, Form Processing, Email, URLs
Simple Javascript CSS Digital Clock
Categories : Java Script, Date Time, CSS, Beginner Guides, Web Design
Adding a Filter to a Text Element
Categories : Java Script, Data Validation, Form Processing
Show hide table rows to make dynamic forms
Categories : Beginner Guides, Java Script, Form Processing, HTTP
Form validations using javascript and including all validations in one message
Categories : HTML and PHP, Java Script, Form Processing
Javascript Background Scroller
Categories : Java Script, CSS, HTML
Form Processing : with alert Highlight field name which is not filled by user
Categories : Java Script, Form Processing, Data Validation, Beginner Guides, Web Design
Upload any fixed type of files, control file type through javascript and encrypt filename using php so file not get overwrite
Categories : PHP, Java Script, Functions, PHP References, Form Processing
Javascript animated menu items
Categories : DHTML, CSS, Java Script, HTML
Page Loading Message shown during the time your site's page is being loaded.
Categories : HTML, CSS, Java Script
day and week grid with clickable fields on/off and possibility to insert in DB
Categories : PHP, Java Script, CSS
Conditional Check - a script that allows a user to submit a form only if the user check a checkbox.
Categories : HTML, Java Script, Form Processing, Beginner Guides
PHP and javascript mouseover, mouseout, and mousedown events
Categories : PHP, Java Script, Form Processing, Beginner Guides
PHP Calendar
Categories : PHP, Calendar, Date Time, Java Script, CSS