We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Suppressing repeating data in report

pooja74
pooja74 asked
on
Medium Priority
471 Views
Last Modified: 2008-02-01
Please tell me how to do the following using javascript.My report  is in tabular form.It is not using any font for the table data.

Using perl-cgi I am  generating a html.This html
is
being displayed on webserver.My requirement is when we display the report it should not show
the repeating ordno.If the order number is different then it should display
the order number.
I mean my report should be like this.
Ordno  Cust Type Name City Country
45554   Bill To  ccc   ggg  ggg
        Ship To  yyy   iii  jjj
        end user yyy   kkk  llll
66665   Bill To  kkk   lll  ooo
        Ship To  nnn   jjj  jjj
I do not want this.
Ordno  Cust Type Name City Country
45554   Bill To  ccc   ggg  ggg
45554   Ship To  yyy   iii  jjj
45554   end user yyy   kkk  llll
66665   Bill To  kkk   lll  ooo
66665   Ship To  nnn   jjj  jjj
Right now  I am using perl-cgi I am able to suppress the  repeating
order
number.But This program is taking long time to display the report.As
the
data in the report is 7500.
So please tell me how to include the javascript  in this report.
The report is being generated by perl-cgi program.
Please write me the code.I shall be highly thankful to you.
Thanks.
Pooja74
Comment
Watch Question

Author

Commented:
Right now i get the report using perl-cgi like the way i want.But using javascript to suppress the repeating order numbers.Will this be more efficient.Is it going to load the more quickly.
Thanks.
Pooja
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
JavaScript is less effective then Perl and will surely need longer to load dynamicaly your page and will NOT display in all browsers (Perl method will display in any browser)

Author

Commented:
OK,Thanks for the reply.But please tell me how to do this in javascript.
Pooja74
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
It depends on your html page format.
Are your data placed in <table> cells?
Or is that all plain text?
Can you post an html example from the browser html source? (of course shortened, not sevet thousand rows)

Author

Commented:
Hi,Here is top of the html code generated .
Thanks for the reply.
Pooja

<TABLE ><TR><TD>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=640>
  <TBODY>
  <TR>
    <TD bgColor=#000000>
      <TABLE border=0 cellPadding=0 cellSpacing=0>
        <TBODY>
        <TR>
          <FORM action=http://directory.cisco.com/index.cgi method=post>
          <TD height=28 vAlign=center width=505><A
            href="http://wwwin.cisco.com/images/navbar/navbar.map"><IMG
            alt="CEC Toolbar" border=0 height=28 isMap
            src="/cto/legal/wa_matrix/images/navbar.gif" width=505></A> </TD>
          <TD height=28 vAlign=center><FONT
            face="Arial, Helvetica, sans-serif" size=-2>&nbsp;<INPUT name=name
            size=10 enctype="text"></FONT> </TD>
          <TD height=28 vAlign=center>&nbsp;<INPUT alt=go border=0 cache
            height=21 src="/cto/legal/wa_matrix/images/dir_go.gif" type=image
            width=25>&nbsp; </TD></FORM></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>

<html><head><title>Written Assurance</title></head><body  BGCOLOR="#FFFAFO"><h1 align="center">Written Assurance</h1><p><table border=1 BORDERCOLOR="BLUE"  WIDTH=640 CELLSPACING="0" ><tr  BGCOLOR="#CCCC99"><th>Order No</th><th>Customer Type</th><th>Name</th><th>City
</th><th>Country</th><th>Written Assurance File</th><th>Found/Not Found</th></tr><TR>
   
      <TD rowspan="3" align=center valign=middle width="11%">41264460-1</TD>
      <TD width="2%">Bill To</TD>
      <TD width="35%">Akademi Ofset</TD>
      <TD width="20%">Istanbul</TD>
      <TD width="15%">Turkey</TD>
      <TD width="20%">144      Akademi Ofset      Istanbul      Turkey             Apr-05
</TD>
      <TD width="5%">Matches</TD>
</TR>
<TR>
      <!-- <TD>41264460-1</TD> -->
    <TD width="2%">End User</TD>
      <TD width="35%">Akademi Ofset</TD>
      <TD width="20%">Istanbul</TD>
      <TD width="15%">Turkey</TD>
      <TD width="20%">144      Akademi Ofset      Istanbul      Turkey             Apr-05
</TD>
      <TD width="5%">Matches</TD>
   
</TR>
<TR>
      <!-- <TD>41264460-1</TD> -->
    <TD width="2%">Ship To</TD>
      <TD width="35%">Akbank</TD>
      <TD width="20%">Istanbul</TD>
      <TD width="15%">Turkey</TD>
      <TD width="20%">145      Akbank      Istanbul      Turkey             Sep-04
</TD>
      <TD width="5%">Matches</TD>
   
</TR>
<TR>
   
      <TD rowspan="3" align=center valign=middle width="11%">41282903-1</TD>
      <TD width="2%">Bill To</TD>
      <TD width="35%">GMD SA</TD>
      <TD width="20%">LIMA</TD>
      <TD width="15%">PERU</TD>
      <TD width="20%">2086      Gmd Sa      Lima      Peru             Jul-05
</TD>
      <TD width="5%">Matches</TD>
</TR>
<TR>
      <!-- <TD>41282903-1</TD> -->
    <TD width="2%">End User</TD>
      <TD width="35%">Dubai Internet City</TD>
      <TD width="20%">Dubai</TD>
      <TD width="15%">United Arab Emirate</TD>
      <TD width="20%">1629      Dubai Internet City      Dubai       United Arab Emirate            Mar-05
</TD>
      <TD width="5%">Matches</TD>
   
</TR>
<TR>
      <!-- <TD>41282903-1</TD> -->
    <TD width="2%">Ship To</TD>
      <TD width="35%">GMD SA</TD>
      <TD width="20%">LIMA</TD>
      <TD width="15%">PERU</TD>
      <TD width="20%">2086      Gmd Sa      Lima      Peru             Jul-05
</TD>
      <TD width="5%">Matches</TD>
   
</TR>
<TR>
   
      <TD rowspan="3" align=center valign=middle width="11%">41301413-1</TD>
      <TD width="2%">Bill To</TD>
      <TD width="35%">GMD SA</TD>
      <TD width="20%">LIMA</TD>
      <TD width="15%">PERU</TD>
      <TD width="20%">2086      Gmd Sa      Lima      Peru             Jul-05
</TD>
      <TD width="5%">Matches</TD>
</TR>
Could you post the code generated that includes the repeating order no.s?
Here is an example:

<script>
function noRepeat(id){
var nums=";",cnt;
var obj=document.getElementById(id).firstChild,n;
for(i=1;i<obj.childNodes.length;i++){
    n=obj.childNodes[i].firstChild.innerHTML;
    if(nums.indexOf(";"+n+";")!=-1){obj.childNodes[i].firstChild.innerHTML="&nbsp;";}
    else{nums+=n+";";}
  }
}
</script>

<button onclick="noRepeat('tableID');">Remove Repeating</button>

<table id=tableID border=1>
<tr><td>Head</td><td>Head</td></tr>

<tr id=r1><td>1</td><td>Text 1</td></tr>
<tr><td>1</td><td>Text 2</td></tr>
<tr><td>1</td><td>Text 3</td></tr>

<tr><td>2</td><td>Text 1</td></tr>
<tr><td>2</td><td>Text 2</td></tr>
<tr><td>2</td><td>Text 3</td></tr>

</table>

Author

Commented:
I donot have any button in my report.Why you have used button onclick.Please reply.
Thanks
I used a button so you can see how it looks like before and after. If you want the page to sort immediately after the page is loaded, take out the button and use body onload instead:

<body onload="noRepeat('tableID');">

Author

Commented:
Hi,
Thanks for replying.I am doing cut and paste of the perl script.
Please tell me where to cut and paste this javascript code.
Thanks.
Pooja74
#!/usr/local/bin/perl

BEGIN {
    require "httpd-paths.ph" || die "$0: can't load httpd-paths.ph: $!";
}
require "errorHandler.pl";
require 'wa_vars.lib';
use CGI;
use DBI;

$ct=0;
my (@fields,$idNum,@list,$sth_cust,$matchkey);
my %filehash=();
my %tablehash=();
$prevrow="  ";
$header=&pageHeader;
$trailer=&pageFooter;
$filename=qq($HTTPDpaths::ChrootRoot/data-shared/cto/legal/export/tools/data/wa_data.db);


open (INFILE,$filename) ||ReportError("Cannot open '$filename'");
while (my $line=<INFILE>)
{
  @list=split(/\t/,$line);

   $list[1] =~ s/^\s*|\s*$|\"|\'|\(|\)|\.|\,|\-|\&|\@|\/|\!//g;
   $list[2] =~ s/^\s*|\s*$|\"|\'|\(|\)|\.|\,|\-|\&|\@|\/|\!//g;
   $list[3] =~ s/^\s*|\s*$|\"|\'|\(|\)|\.|\,|\-|\&|\@|\/|\!//g;
   my $hashkey = uc("$list[1];$list[2];$list[3]");
  $filehash{$hashkey} = $line;
}


print "Content-type: text/html\n\n";
print $header;
print "<html><head><title>Written Assurance";
print "</title></head><body  BGCOLOR=\"#FFFAFO\"><h1 align=\"center\">";
print "Written Assurance</h1><p>";
my $dbh = DBI->connect( 'dbi:Oracle:sjdev',
                        'apps',
                        'g00g1e',
                        {
                          RaiseError => 1,
                          AutoCommit => 0
                        }
                      ) || die "Database connection not made: $DBI::errstr";

my $sql_cust =qq{select  a.ordno,'Ship To',b.pname,b.pcity,b.pcountry,1
from billto  b,ordero a
where a.pid =b.pid
and  a.status='H'
union
select  a.ordno,'Bill To',b.uname,b.ucity,b.ucountry,2
from shipto  b,ordero a
where a.u_id =b.u_id
and  a.status='H'
union
select  a.ordno,'End User',b.uname,b.ucity,b.ucountry,3
from shipto  b,ordero a
where a.nid =b.nid
and  a.status='H'

order by 1};

PrintHeading();

$sth_cust = $dbh->prepare( $sql_cust )or die "error in prepare \n";
       
$sth_cust->execute() or die "Can't execute SQL statement: $DBI::errstr\n";
$custtype=1;
 while ( my @row = $sth_cust->fetchrow_array ){
   $row[0] =~ s/^\s*|\s*$//g;
   $row[1] =~ s/^\s*|\s*$//g;
   $row[2] =~ s/^\s*|\s*$|\"|\'|\(|\)|\.|\,|\-|\&|\@|\/|\!//g;
   $row[3] =~ s/^\s*|\s*$|\"|\'|\(|\)|\.|\,|\-|\&|\@|\/|\!//g;
   $row[4] =~ s/^\s*|\s*$|\"|\'|\(|\)|\.|\,|\-|\&|\@|\/|\!//g;
   $currow=$row[0];
   $matchkey =uc("$row[2];$row[3];$row[4]");
  # push(@ordero_notfound,"$row[0];$row[1];$row[2];$row[3];$row[4]");
 
    if (defined($filehash{$matchkey}))
    {                       print "<tr>";
                            TableRow( $row[0]);
                            TableRow($row[1]);
                            TableRow($row[2]);
                            TableRow($row[3]);
                            TableRow($row[4]);
                            TableRow(" Matches") ;
                  $match=uc("$row[2];$row[3];$row[4]");
                            TableRow($filehash{$match});
                             print "</tr>";

                      }
         
       else {
      push(@ord_notfound,"$row[0];$row[1];$row[2];$row[3];$row[4]");

 
            }

         }
$custtype_nf=1;
foreach(@ord_notfound)
                        {  print "<tr>";
                         @row_ord=split (/;/,$_);
                           TableRow( $row_ord[0]);
                            TableRow($row_ord[1]);
                            TableRow($row_ord[2]);
                            TableRow($row_ord[3]);
                            TableRow($row_ord[4]);
                            TableRow("Not Matches") ;
                            print "</tr>";
                           
                                }

print "</table>\n";
print "</body></html>\n";
print $trailer;

$sth_cust->finish();
$dbh->disconnect()or warn "Error disconnecting: $DBI::errstr\n";
exit(0);

sub  TableRow {
   my ($val)=@_;
   if ($val eq ""){$val="\&nbsp";}
   print "<td>";
   print  $val;
   print "</td>";
              }

sub PrintHeading {
print "<table border=1 BORDERCOLOR=\"BLUE\"  CELLSPACING=\"0\" >\n";
print "<tr  BGCOLOR=\"#CCCC99\">";
print "<th>Order No</th><th>Customer Type</th><th>Name</th><th>Cit
y</th><th>Country</th><th>W A Matches</th><th>Wa_data.db Data</th>";
print "</tr>";
                 }
sub pageHeader {
    my $nav_bar = &navBar;
    my $header_html = <<"EOT";
<TABLE WIDTH="640"><TR><TD>
$nav_bar
EOT
    return $header_html;
}
sub navBar {
    my $navBar = <<"EOT";
<TABLE border=0 cellPadding=0 cellSpacing=0 width=640>
  <TBODY>
  <TR>
    <TD bgColor=#000000>
      <TABLE border=0 cellPadding=0 cellSpacing=0>
        <TBODY>
        <TR>
          <FORM action=http://directory.cisco.com/index.cgi method=post>
          <TD height=28 vAlign=center width=505><A
            href="http://wwwin.cisco.com/images/navbar/navbar.map"><IMG
            alt="CEC Toolbar" border=0 height=28 isMap
            src="$::baseDir/images/navbar.gif" width=505></A> </TD>
          <TD height=28 vAlign=center><FONT
            face="Arial, Helvetica, sans-serif" size=-2>&nbsp;<INPUT name=name
            size=10 enctype="text"></FONT> </TD>
          <TD height=28 vAlign=center>&nbsp;<INPUT alt=go border=0 cache
            height=21 src="$::baseDir/images/dir_go.gif" type=image
            width=25>&nbsp; </TD></FORM></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
EOT
    return $navBar;
}

#### HTML for page footer
sub pageFooter {
#    my $nav_bar = &navBar;
    my $footer = <<"EOT";
<P>
<IMG height=5
src="$::baseDir/images/strip.gif" width=640><BR>
<P><Small><B>Cisco Systems, Inc. Internal Use Only</B></Small>
<br><Small>Managed by: <a href=\"mailto:$main::solcat_owner_email\">IT Corporate Affairs</a>
<br>Last Modified on 07/08/2003</Samll></P>
</TD></TR></TABLE>
EOT

#</body></html>
    return $footer;

}
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Hi Venabili,
I think in this case my answer should be accepted since I provided a solution that works, but the asker never responded to my last post.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.