Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Javascript / Client Side Development

show table rows


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

sanju wrote:
> 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

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)

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[i].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[i].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[i]].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[i].style.display = 'none';
    t2[i].getElementsByTagName('INPUT')[0].checked=false;
    }
  }

function chck() {
  var C = new Array();
  var k = 0;
  for(var i=0; i<t1.length; i++)
    if(t1[i].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[i]].style.display = '';
      // t2[C[i]].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>

--
Stephane Moriaux et son (moins) vieux Mac dj dpass
Stephane Moriaux and his (less) old Mac already out of date

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

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.

--
Stephane Moriaux et son (moins) vieux Mac dj dpass
Stephane Moriaux and his (less) old Mac already out of date

ASM wrote:
> 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.

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

Regards,
Erwin Moller

Erwin Moller a crit :

> ASM wrote:

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

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

--
Stephane Moriaux et son (moins) vieux Mac dj dpass
Stephane Moriaux and his (less) old Mac already out of date

On May 15, 7:27 pm, "Evertjan." <exjxw.hannivo@interxnl.net> wrote:

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
sanju wrote on 17 mei 2007 in comp.lang.javascript:

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

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

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

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

Heh.  "Angryness?"  ;)

--
-Lost
Remove the extra words to reply by e-mail.  Don't e-mail me.  I am
kidding.  No I am not.

-Lost wrote on 18 mei 2007 in comp.lang.javascript:

> Evertjan. wrote:

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

> Heh.  "Angryness?"  ;)

Y? [~ Why?]

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

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc