<html>
<form>
<table>

<tr>
    <td width="172" class="label" >&nbsp;</td>
    <td class="content" colspan="3" > Grwt
      <input name="grWeight" type="text" class="box" id="grWeight" size="20" maxlength="255" />
      ntwt
      <input name="netWeight" type="text" class="box" id="netWeight" size="20" maxlength="255" />
      crwt
      <input name="crWeight" type="text" class="box" id="crWeight" size="20" maxlength="255" /></td>
  
  </tr>  
  </table>
  </form>
  </html>

In above code i want to show background of textbox highlighted with color which value greater than other two text boxes.


please help me.

Try this code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<script  language="javascript">
function checkvalue()
{
	var grWeight = parseInt(document.getElementById('grWeight').value);
	var netWeight = parseInt(document.getElementById('netWeight').value);
	var crWeight = parseInt(document.getElementById('crWeight').value);
	
	document.getElementById('grWeight').style.backgroundColor  = '#FFFFFF';
	document.getElementById('netWeight').style.backgroundColor  = '#FFFFFF';
	document.getElementById('crWeight').style.backgroundColor  = '#FFFFFF';
	
	if(grWeight>netWeight && grWeight>crWeight)
		document.getElementById('grWeight').style.backgroundColor  = '#FCF964';
	if(netWeight>grWeight && netWeight>crWeight)
		document.getElementById('netWeight').style.backgroundColor = '#FCF964';
	if(crWeight>netWeight && crWeight>grWeight)
		document.getElementById('crWeight').style.backgroundColor = '#FCF964';
}
</script>
<form>
<table>

<tr>
    <td width="172" class="label" >&nbsp;</td>
    <td class="content" colspan="3" > Grwt
      <input name="grWeight" type="text" class="box" id="grWeight" size="20" maxlength="255" />
      ntwt
      <input name="netWeight" type="text" class="box" id="netWeight" size="20" maxlength="255" />
      crwt
      <input name="crWeight" type="text" class="box" id="crWeight" size="20" maxlength="255" />
      
      <input name="click" value="Click here" onclick="return checkvalue();" type="button" />
      </td>
  
  </tr>  
  </table>
  </form>
</body>
</html>

Thanku very much...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.