0
<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.

2
Contributors
2
Replies
13
Views
6 Years
Discussion Span
Last Post by manu555
0

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>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.