Connecting Tech Pros Worldwide Forums | Help | Site Map

select fullrow

Jon
Guest
 
Posts: n/a
#1: Jul 23 '05
Hi all

Looking for a way to select the fullrow when i click on LAG 3
So it marks all of LAG 3 for July, August, September

If I select LAG 4 it'll select of LAG 4 in the different months

It would very nice if there is a way with Javascript
Follow the link below

http://www.johak.se/schema/index.html


I'am pretty good with Visual Basic 6, and html
But no experience with Javascript
--

Mvh
Jon

jonny.hakansson@comhem.se





Ivo
Guest
 
Posts: n/a
#2: Jul 23 '05

re: select fullrow


"Jon" typed[color=blue]
> Looking for a way to select the fullrow when i click on LAG 3
> So it marks all of LAG 3 for July, August, September
> If I select LAG 4 it'll select of LAG 4 in the different months
>
> It would very nice if there is a way with Javascript
> Follow the link below
> http://www.johak.se/schema/index.html
>[/color]

For example:
<script type="text/javascript">
function hiliteTR(el) {
var cel=el.cells;
var c=cel[0].style.background;
for (var i=cel.length;i--;)
cel[i].style.background= (c=='gold') ? 'none' : 'gold';
}
</script>

This function can be called by adding a so-called onclick event handler,
either to the whole TR or on the first TD only, like so:
<tr onclick="hiliteTR(this)"><td>tada</td><td>tada</td></tr>
<tr><td onclick="hiliteTR(this.parentNode)">tada</td><td>tada</td></tr>

HTH
Ivo


Jon
Guest
 
Posts: n/a
#3: Jul 23 '05

re: select fullrow


Ok

Yes it worked perfectly.

But I need it too work on several rows at the sametime

Everytime I click on LAG 1, the row that start's with LAG 1
will be highlighted.





"Ivo" <no@thank.you> skrev i meddelandet
news:40bdeb8a$0$153$18b6e80@news.wanadoo.nl...[color=blue]
> "Jon" typed[color=green]
> > Looking for a way to select the fullrow when i click on LAG 3
> > So it marks all of LAG 3 for July, August, September
> > If I select LAG 4 it'll select of LAG 4 in the different months
> >
> > It would very nice if there is a way with Javascript
> > Follow the link below
> > http://www.johak.se/schema/index.html
> >[/color]
>
> For example:
> <script type="text/javascript">
> function hiliteTR(el) {
> var cel=el.cells;
> var c=cel[0].style.background;
> for (var i=cel.length;i--;)
> cel[i].style.background= (c=='gold') ? 'none' : 'gold';
> }
> </script>
>
> This function can be called by adding a so-called onclick event handler,
> either to the whole TR or on the first TD only, like so:
> <tr onclick="hiliteTR(this)"><td>tada</td><td>tada</td></tr>
> <tr><td onclick="hiliteTR(this.parentNode)">tada</td><td>tada</td></tr>
>
> HTH
> Ivo
>
>[/color]


Ivo
Guest
 
Posts: n/a
#4: Jul 23 '05

re: select fullrow


"Jon" wrote[color=blue]
> "Ivo" skrev[color=green]
> > "Jon" typed[color=darkred]
> > > Looking for a way to select the fullrow when i click on LAG 3
> > > So it marks all of LAG 3 for July, August, September
> > > If I select LAG 4 it'll select of LAG 4 in the different months
> > >
> > > It would very nice if there is a way with Javascript
> > > Follow the link below
> > > http://www.johak.se/schema/index.html
> > >[/color][/color][/color]
<snip script>[color=blue]
>
> Yes it worked perfectly.
> But I need it too work on several rows at the sametime
>[/color]

I see. The following function does that (it also sets the background on the
TR deirectly and not on its TD's separately as did the previous function for
no good reason):

function hiliteTR(el) {
var col= (el.style.background=='gold') ? 'none' : 'gold';
var r=0; while(el=el.previousSibling) r++;
var t=document.getElementsByTagName('table');
for(var i=t.length; i--; ) t[i].rows[r].style.background=col;
}

You keep add more tabels with more months to the page and the script will
find them. See it in action at http://4umi.com/test2.htm where I have also
made a beginning with moving some stuff out of the HTML into a stylesheet.
HTH
Ivo


Jon
Guest
 
Posts: n/a
#5: Jul 23 '05

re: select fullrow


Thanks

It's works perfectly

Jon


"Ivo" <no@thank.you> skrev i meddelandet
news:40bef187$0$1757$abc4f4c3@news.wanadoo.nl...[color=blue]
> "Jon" wrote[color=green]
> > "Ivo" skrev[color=darkred]
> > > "Jon" typed
> > > > Looking for a way to select the fullrow when i click on LAG 3
> > > > So it marks all of LAG 3 for July, August, September
> > > > If I select LAG 4 it'll select of LAG 4 in the different months
> > > >
> > > > It would very nice if there is a way with Javascript
> > > > Follow the link below
> > > > http://www.johak.se/schema/index.html
> > > >[/color][/color]
> <snip script>[color=green]
> >
> > Yes it worked perfectly.
> > But I need it too work on several rows at the sametime
> >[/color]
>
> I see. The following function does that (it also sets the background on[/color]
the[color=blue]
> TR deirectly and not on its TD's separately as did the previous function[/color]
for[color=blue]
> no good reason):
>
> function hiliteTR(el) {
> var col= (el.style.background=='gold') ? 'none' : 'gold';
> var r=0; while(el=el.previousSibling) r++;
> var t=document.getElementsByTagName('table');
> for(var i=t.length; i--; ) t[i].rows[r].style.background=col;
> }
>
> You keep add more tabels with more months to the page and the script will
> find them. See it in action at http://4umi.com/test2.htm where I have also
> made a beginning with moving some stuff out of the HTML into a stylesheet.
> HTH
> Ivo
>
>[/color]


Closed Thread