Solved

Suppressing repeating data in report

Posted on 2004-03-24
16
395 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
0
Comment
Question by:pooja74
  • 5
  • 5
  • 2
16 Comments
 

Author Comment

by:pooja74
ID: 10669790
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
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10671159
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)
0
 

Author Comment

by:pooja74
ID: 10671281
OK,Thanks for the reply.But please tell me how to do this in javascript.
Pooja74
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10671308
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)
0
 

Author Comment

by:pooja74
ID: 10672336
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>
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 10673348
Could you post the code generated that includes the repeating order no.s?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 12

Expert Comment

by:lil_puffball
ID: 10673456
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>
0
 

Author Comment

by:pooja74
ID: 10680898
I donot have any button in my report.Why you have used button onclick.Please reply.
Thanks
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 10681451
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');">
0
 

Author Comment

by:pooja74
ID: 10682338
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;

}
0
 
LVL 12

Accepted Solution

by:
lil_puffball earned 250 total points
ID: 10682875
I actually have no experience with perl...
but you would put the javascript in the same way you put the html in.

Perhaps something like this right after you print the head tag:

print "<script>function noRepeat(id){var nums=";",cnt;var obj=document.getElementById(id).firstChild,n;";
print "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>

Also, in your table, make sure you give it the id tableID, like this:

<table id=tableID cellspacing=0 ... >

And where you print the body tag, do this:

print "</title></head><body  BGCOLOR=\"#FFFAFO\" onload=\"noRepeat('tableID');\"><h1 align=\"center\">";
0
 
LVL 12

Expert Comment

by:lil_puffball
ID: 11054276
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.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now