show table rows

S

sanju

Hi all,
I am new in the world of javascript. Someone plz help me.
I have two tables containing 30 rows each. In first table there is
checkbox and in the second table there is radio buttons ahead each
row. If i select 5th & 6th row from first table then it should show
only the 5th & 6th row from the second table. The rows are same in
both table. Likewise the rows i select from first table should only
display from the second table..
plz help me..I want it very argent.

Thanks in advance...
 
E

Erwin Moller

sanju said:
Hi all,
I am new in the world of javascript. Someone plz help me.
I have two tables containing 30 rows each. In first table there is
checkbox and in the second table there is radio buttons ahead each
row. If i select 5th & 6th row from first table then it should show
only the 5th & 6th row from the second table. The rows are same in
both table. Likewise the rows i select from first table should only
display from the second table..
plz help me..I want it very argent.

Thanks in advance...

Hi,

If you are really new to JavaScript, don't expect you'll solve your problem
with a posting to this ng.
The reason is simply that is will be difficult for anybody to help you if
you know nothing about javascript.

eg: Expect answers/questions like:
- Give every td an unique ID.
- what are the values in the radiogroup? and what is their name?
etc.

Probably all over your head and might very well result in a lot more
timeloss for you trying to understand what goes wrong.

The good news is: What you are asking for is very basic.
I would advise you to hire a JavaScript programmer for one day and fix your
app as you desire.
(s)he can probably also fix/build a few other things if any good in 1 day.
;-)
just my 2 cent.
Good luck.

Regards,
Erwin Moller
 
E

Evertjan.

Erwin Moller wrote on 15 mei 2007 in comp.lang.javascript:
Hi,

If you are really new to JavaScript, don't expect you'll solve your
problem with a posting to this ng.
The reason is simply that is will be difficult for anybody to help you
if you know nothing about javascript.

Another reason is that we don't do Sanju's school assignment.
 
A

ASM

sanju a écrit :
Hi all,
I am new in the world of javascript. Someone plz help me.
I have two tables containing 30 rows each. In first table there is
checkbox and in the second table there is radio buttons ahead each
row. If i select 5th & 6th row from first table then it should show
only the 5th & 6th row from the second table. The rows are same in
both table. Likewise the rows i select from first table should only
display from the second table..

You must hide by JS each row of 2nd table

function hid() {
var t2 = document.getElementById('table2');
t2 = t2.getElementsByTagName('TBODY')[0].rows;
for(var i=0; i<t2.length; i++)
t2.style.display = 'none';
}

Then you must to have a function to see what is checked

function chck() {
var C = new Array();
var k = 0;
var t1 = document.getElementById('table2');
t1 = t1.getElementsByTagName('TBODY')[0].rows;
for(var i=0; i<t2.length; i++)
if(t2.getElementsByTagName('INPUT')[0].checked) {
C[k] = i;
k++;
}
return C;
}

And something to reveal correct rows :

function myRows() {
hid();
var C = chck();
var t2 = document.getElementById('table2');
t2 = t2.getElementsByTagName('TBODY')[0].rows;
for(var i=0; i<C.length; i++)
t2[C].style.display = '';
}





<html>
<script type="text/javascript">
var t1, t2;
function init() {
t1 = document.getElementById('table1');
t1 = t1.getElementsByTagName('TBODY')[0].rows;
t2 = document.getElementById('table2');
t2 = t2.getElementsByTagName('TBODY')[0].rows;
hid();
}
onload = init;

function hid() {
for(var i=0; i<t2.length; i++) {
t2.style.display = 'none';
t2.getElementsByTagName('INPUT')[0].checked=false;
}
}

function chck() {
var C = new Array();
var k = 0;
for(var i=0; i<t1.length; i++)
if(t1.getElementsByTagName('INPUT')[0].checked) {
C[k] = i;
k++;
}
return C;
}

function myRows() {
hid();
var C = chck();
for(var i=0; i<C.length; i++) {
t2[C].style.display = '';
// t2[C].getElementsByTagName('INPUT')[0].checked=true;
}
}

</script>
<form>
<table id="table1" border="1" width="90%" cellspacing="2">
<tr>
<td><input type=checkbox onclick="myRows()"></td>
<td>_Row_1_Cell_2_</td>
<td>_Row_1_Cell_3_</td>
</tr>
<tr>
<td><input type=checkbox onclick="myRows()"></td>
<td>_Row_2_Cell_2_</td>
<td>_Row_2_Cell_3_</td>
</tr>
<tr>
<td><input type=checkbox onclick="myRows()"></td>
<td>_Row_3_Cell_2_</td>
<td>_Row_3_Cell_3_</td>
</tr>
<tr>
<td><input type=checkbox onclick="myRows()"></td>
<td>_Row_4_Cell_2_</td>
<td>_Row_4_Cell_3_</td>
</tr>
<tr>
<td><input type=checkbox onclick="myRows()"></td>
<td>_Row_5_Cell_2_</td>
<td>_Row_5_Cell_3_</td>
</tr>
</table>

<table id="table2" border="1" width="90%" cellspacing="2">
<tr>
<td><input type=radio name=rad></td>
<td>_Row_1_Cell_2_</td>
<td>_Row_1_Cell_3_</td>
</tr>
<tr>
<td><input type=radio name=rad></td>
<td>_Row_2_Cell_2_</td>
<td>_Row_2_Cell_3_</td>
</tr>
<tr>
<td><input type=radio name=rad></td>
<td>_Row_3_Cell_2_</td>
<td>_Row_3_Cell_3_</td>
</tr>
<tr>
<td><input type=radio name=rad></td>
<td>_Row_4_Cell_2_</td>
<td>_Row_4_Cell_3_</td>
</tr>
<tr>
<td><input type=radio name=rad></td>
<td>_Row_5_Cell_2_</td>
<td>_Row_5_Cell_3_</td>
</tr>
</table>
</form>
</html>
 
E

Erwin Moller

Evertjan. said:
Erwin Moller wrote on 15 mei 2007 in comp.lang.javascript:


Another reason is that we don't do Sanju's school assignment.

LOL, yeah. ;-)
Could also be true.

BTW: ASM wrote a lengthy answer that looks good.
However, I wonder if the OP can use it...

Regards,
Erwin Moller
 
A

ASM

Erwin Moller a écrit :
BTW: ASM wrote a lengthy answer that looks good.

Tested in FF
However, I wonder if the OP can use it...

I certainly will not give commented code in first answer.
He will have to do it himself, showing by that he understand.

If he doesn't understand sg he'll can come back and ask.
 
E

Erwin Moller

ASM said:
Erwin Moller a écrit :

Tested in FF


I certainly will not give commented code in first answer.
He will have to do it himself, showing by that he understand.

If he doesn't understand sg he'll can come back and ask.

Looks like Sanju is too busy to check out your excellent answer...

Regards,
Erwin Moller
 
A

ASM

Erwin Moller a écrit :
He could : 1st part of what I've given is wrong (can't work)
Looks like Sanju is too busy to check out your excellent answer...

:))

I do not wait something from those who question
 
S

sanju

Erwin Moller wrote on 15 mei 2007 in comp.lang.javascript:






Another reason is that we don't do Sanju's school assignment.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)- Hide quoted text -

- Show quoted text -

Dont act very smart!!!! r u owner of this group?
i dont like to give answer to ur foolish thing...dont think abt
me...think abt ur self, it will help u in future
 
E

Evertjan.

sanju wrote on 17 mei 2007 in comp.lang.javascript:
Dont act very smart!!!! r u owner of this group?
i dont like to give answer to ur foolish thing...dont think abt
me...think abt ur self, it will help u in future

You seem to mistake usenet for sms, go and learn first, Sanju.
In your angryness you expose yourself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,427
Latest member
HildredDic

Latest Threads

Top