Page 1 of 1
How can I highlight a <tr> row when clicking it?
Posted: Fri Nov 13, 2015 4:13 am
by simonmlewis
We need to highlight rows when they are clicked. Sounds easy enough.
Problem is, in the row there are Form Submit buttons, and one Ajax input field.
When we used an onclick event, it would render the value of the ajax field to be "True", rather than what should be in there.
It also seems to disable the Edit 'submit' buttons from passing over all the information to the following page.
So is there a nice little method for highlighting the row?
Re: How can I highlight a <tr> row when clicking it?
Posted: Fri Nov 13, 2015 6:33 am
by Celauran
A click handler is how I'd approach this and I see no reason for the side effects. Other code interfering maybe. I'd literally just define a class for the highlighting and toggle the class on click.
Re: How can I highlight a <tr> row when clicking it?
Posted: Fri Nov 13, 2015 7:18 am
by simonmlewis
It needs to be able to highlight as many rows as are clicked, it's so that admins can see what is "completed".
Any suggestions of how to code it?
Re: How can I highlight a <tr> row when clicking it?
Posted: Fri Nov 13, 2015 7:57 am
by Celauran
Re: How can I highlight a <tr> row when clicking it?
Posted: Fri Nov 13, 2015 8:14 am
by simonmlewis
I cannot get it to work.
And I don't understand how it is knowing that the class "someclass" is assigned to that specific table??
Re: How can I highlight a <tr> row when clicking it?
Posted: Fri Nov 13, 2015 8:23 am
by Celauran
simonmlewis wrote:I cannot get it to work.
Well post what you've got into a Fiddle and let's take a look.
Re: How can I highlight a <tr> row when clicking it?
Posted: Fri Nov 13, 2015 8:30 am
by simonmlewis
Sorry I see what you are doing now.
You are basically saying any "<tr>" tag, is assigned to use that "someclass".
I have mouseover code working, so maybe that is disabling it.
Re: How can I highlight a <tr> row when clicking it?
Posted: Fri Nov 13, 2015 8:46 am
by Celauran
simonmlewis wrote:You are basically saying any "<tr>" tag, is assigned to use that "someclass".
Right, exactly. You'd need to tailor that to your needs, add in any additional functionality you'd require on click, etc. I tried to keep the example as simple as possible.
Re: How can I highlight a <tr> row when clicking it?
Posted: Fri Nov 13, 2015 8:50 am
by simonmlewis
Sure. I think because I have the following, it's not allowing it to work:
Code: Select all
<tr ";
$resultrccart = mysql_query ("SELECT romancartcatid FROM subcategories WHERE subid = '$row->subid'");
while ($rowrccart = mysql_fetch_object($resultrccart))
{
// is there a romancart cat id for out of stock?
if (isset($rowrccart->romancartcatid))
{
// yes? Then check if the romancart code has a hyphen in it
if (preg_match("/-/i", "$row->romancode"))
{
echo " bgcolor='#009BF4' onMouseOver=\"this.bgColor='#009BF4';\" onMouseOut=\"this.bgColor='#009BF4';\"";
}
}
} mysql_free_result($resultrccart);
if ($row->pause == "on") { echo " bgcolor='#FF7B00'";}
else { echo " bgcolor='#ffffff' onMouseOver=\"this.bgColor='#E7E7E7';\" onMouseOut=\"this.bgColor='#FFFFFF';\"";}
echo ">
It's being overridden. Bugger.
Re: How can I highlight a <tr> row when clicking it?
Posted: Fri Nov 13, 2015 9:08 am
by Celauran
You really don't want any of that inline. Move it to classes and then use your logic to determine which class to display. Much cleaner.
Re: How can I highlight a <tr> row when clicking it?
Posted: Fri Nov 13, 2015 9:19 am
by simonmlewis
Yes I know what you mean. some of it is old code, that we haven't replaced. And of course, as it's hard coded, it's taking priority.
Re: How can I highlight a <tr> row when clicking it?
Posted: Fri Nov 13, 2015 9:32 am
by Celauran
Looks like a good time to clean that up, then, as it's causing problems with new functionality you're trying to implement.
Re: How can I highlight a <tr> row when clicking it?
Posted: Tue Apr 05, 2016 11:43 am
by thinsoldier
I literally do not remember the last time I've seen onMouseOut! You definitely need to move all that stuff to simple css classes.