Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onFocust="DoFunction('rowname');" to highlight a row - Need help! 2

Status
Not open for further replies.

josel

Programmer
Oct 16, 2001
716
US
Howdy!

I have scripts
Code:
<script type="text/javascript" language="JavaScript">
	function HighLight(xRow) {
	document.getElementByName(val).background=#CCCCCC;
	}
	
	function noHighLight(xRow) {
	document.getElementByName(xRow).background=#FFFFFF; 
	}
	
</script>
</code]

and form fields with
[code]
	<tr class="boxed" name="tblrow1">
	<td class="boxed" >BB3-3 MODENA</td>
	<td class="boxed" >ROSETTE FLUTED OVERLAY BLOCK - .75</td>
	<td class="boxed" >MODENA</td>
	<td class="boxed"  align="right">0.00</td>
	<td class="boxed"  align="right">0.00</td>
	<td class="boxed"  align="right">0.00</td>
	<td class="boxed"  align="right">0.00</td>
	<td  class="boxed" align="right">18.00</td>
	<td class="boxed"><input name="QTYSOLD1" type="text" size="9" maxsize="9" onFocus="HighLight('tblrow1');" onBlur="noHighLight('tblrow1');"></td>

It does not work. I get error on <input> field line.

All I want to do is highlight the row in which the input field is. I've seen this in some pages and would like to have identical effect on my page.

What am I doing wrong?

Thank you all in advance!


Jose Lerebours



KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
Perhaps because you're passing "xRow", but using "val"?:

Code:
function HighLight([!]xRow[/!]) {
   document.getElementByName([!]val[/!]).background=#CCCCCC;
}

Also, you need to put quotes around your colour values in both functions, and refer to "style.background", not just background:

Code:
.style.background = '#CCCCCC';

You can also refer to "backgroundColor" instead if you don't want to set all background properties:

Code:
.style.backgroundColor = '#CCCCCC';

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi

And how is defined the [tt]getElementByName()[/tt] method ? Anyway, the [tt]tr[/tt] tag has no name attribute.

Am I rude if I say that your code is seems to be randomly generated ?
Code:
<script type="text/javascript" language="JavaScript">
    function HighLight(xRow) {
    document.getElementBy[red]Id[/red]([red]xRow[/red])[red].style[/red].background[red]Color[/red]=[red]'[/red]#CCCCCC[red]'[/red];
    }
    
    function noHighLight(xRow) {
    document.getElementBy[red]Id[/red](xRow)[red].style[/red].background[red]Color[/red]=[red]'[/red]#FFFFFF[red]'[/red];
    }
</script>
Code:
    <tr class="boxed" [red]id[/red]="tblrow1">

Feherke.
 
I will revise my code following your suggestions. The code is dynamically generated using PHP and it is based on a mySQL table content.

Thank you both!


Jose Lerebours


KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
It works now !!!

I really need to pay more attention to these little details that make a big difference. I am now getting the exact behavior I was looking for. I have even taken it to the next level and set the row to yellow if onBlur field is not blank.

Thank so very much ...


Jose Lerebours


KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top