#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    2

    Check all checkboxes with the first checkbox and print values of row that is checked


    I have created a code where i have a table with some checkboxes and values. What i want to do is to check all checkboxes with the first one and uncheck them. After that with the button "click" i want to print data from the row that is checked. I need some help because what i have done doesn't work
    Code:
    my $script = qq{
    \$('table tr td:first-child input').click(function(event){
      if (\$(this).is(':checked')) {
        \$(this).parent().parent().find("td input:not(:checked)").click();
      } else {
        \$(this).parent().parent().find("td input:checked").click();
      }
    }); 
    
    \$("#button").click(function(){
    \$("td.checkbox>input:checked").parent().parent("tr").print();
    }
    };
    
    my $q= new CGI;
    print $q->start_html(
    -title=>"Table",
    -style  => {-src =>'css/ui-lightness/jquery-ui-1.10.3.custom.css" rel="stylesheet'},
         -script => [
            {-src =>'js/jquery-1.9.1.js'}, 
            {-src =>'js/jquery-ui-1.10.3.custom.js'
                    
            }, 
          ],   
    );
    my @aRows = ();
    
    my $oCheckAll = $q->input({-type => 'checkbox', -name => 'sel_all', -id =>'id', }, 'Select All');
    
    
    # Add header of table
    push @aRows, (
       $q->Tr($q->th([$oCheckAll, 'Emri', 'Mbiemri', 'Datelindja'])),   
    );
    
    # Add table rows
    for(my $i=0; $i<4; $i++) {
       push @aRows, (
          $q->Tr($q->td([$q->input({-class => 'checkbox', -type => 'checkbox' }), "EMR", "MB", $i]))
       );
    }
    
    print $q->style(".table th, td { width: 25%;}");
    
    print $q->table({-class => 'table', -border => 1, -width => '100%'}, \@aRows);
    print $q->button(
            -id       => 'button',
            -name     => 'submit_form',
            -value    => 'click',
        );
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    27
    Oh, perl, how I do not miss you.

    A couple thoughts:
    * you don't output $script into your webpage anywhere?
    * print() is not a jquery function?

IMN logo majestic logo threadwatch logo seochat tools logo