Page is a not externally linkable
birdbrain - 9:51 am on Jun 8, 2012 (gmt 0)
Hi there Rain_Lover,
as CSS seems to be ineffective for this task, try this...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Sample Form</title>
<style type="text/css">
.focused {
background-color:#fdb;
}
</style>
<script type="text/javascript">
function init(){
inp=document.getElementsByTagName('input');
for(c=0;c<inp.length;c++){
inp[c].onfocus=function() {
if(this.previousSibling.nodeName=='LABEL'){
this.previousSibling.className='focused';
this.onblur=function() {
this.previousSibling.className='';
}
}
}
}
}
window.addEventListener?
window.addEventListener('load',init,false):
window.attachEvent('onload',init);
</script>
</head>
<body>
<form action="#">
<label for="fname">First name</label><input type="text" id="fname">
<br>
<label for="lname">Last name</label><input type="text" id="lname">
</form>
</body>
</html>
birdbrain