Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

problem in href and pagination

by rjsaulakh (Beadle)
on Dec 17, 2005 at 13:20 UTC ( #517481=perlquestion: print w/ replies, xml ) Need Help??
rjsaulakh has asked for the wisdom of the Perl Monks concerning the following question:

#!/usr/bin/perl use CGI; my $cgi=new CGI; print $cgi->header; $region = $cgi->param("region"); print <<HERE1; <body> <table WIDTH="525" border="0" cellpadding="0" cell +spacing="0"> <tr><td valign="top" class="bodycont +ent-txt"><p>cant excute the cgi what to do please help. </p></td></tr +> <tr><td valign="top" class="bodycontent-txt"><p>c +ant ee xcute the cgi please help</p></td></tr> <tr><td valign="top" class="bodycontent-txt"><p>c +ant excute the cgi what to do please help. cant excute the cgi what t +o do please help. </p></td></tr> <tr><td valign="top" class="bodycontent-txt"><p> +cant excute the cgi what to do please help. cant excute the cgi what +to do please help. cant excute the cgi what to do please help. </p></ +td></tr> <tr><td valign="top" class="bodycontent-txt">< +img src="images/spacer.gif" width="10" height="10" alt="" ></td></tr> <tr><td valign="top" class="bodycontent-txt"><p>< +strong>In Europa</strong></p></td></tr> <tr><td valign="top" class="bodycontent-txt"> HERE1 pageNumbers(); print <<HERE1; </td></tr> </table> </BODY> HERE1 sub pageNumbers { $count = 0; open (FIN, "data.txt") or die "cant open the file "; while(<FIN>) { $count++ } $totalcount= $count; print "$totalcount \n \n "; #so put all the values inside an array say @total. $no_per_page=15; $total_pages=int((scalar $totalcount) / $no_per_page); print "$total_pages \n \n "; $remainder = (scalar $totalcount) % $no_per_page; if ($remainder) { $total_pages++; print $total_pages; } if($total_pages) { print <<"END"; <table cellpadding="0" cellspacing="0" bor +der="0" width="100%"> <tr> <td class="smtxt"> END print "<b>Page&nbsp;</b>"; for $i (1 .. $total_pages) { if ($i == $page) { print "<b>$i</b>"; } else { print "<a href=\"categories.cgi ?page=$i&peri +od=$period\">$i</a>"; } if ($i != $total_pages) { print "&nbsp;|&nbsp;"; } } print "<!-- '$total_pages' '$remainder' --></td></tr></table>\ +n"; } } 1;

in this code i have my pagelinks. i want that whatever page link is clicked the corresponding text should be displayed after the page links and in the same page a new page shuld not be loaded . the new data should come in the same page how can i do that please help

READMORE tags added by Arunbear

Comment on problem in href and pagination
Download Code
Re: problem in href and pagination
by chas (Priest) on Dec 17, 2005 at 15:43 UTC
    "a new page shuld not be loaded . the new data should come in the same page"
    You could simulate that using frames, possibly.
    A lot of your code doesn't make much sense to me. For example;
    for $i (1 .. $total_pages) { if ($i == $page)...
    I don't see that $page has ever been defined. You should use warnings; and use strict;, check your code using perl -c yourscript.pl, and some of the obvious errors will be revealed to you.
    (Also, if you try to use correct spelling and formatting - like beginning sentences with caps, putting periods or question marks at the ends of sentences, etc, and generally make it look as if you took some care in your posting, you may get more responses, at least IMHO.)
Re: problem in href and pagination
by Joost (Canon) on Dec 17, 2005 at 16:04 UTC
    You've just made 3 new posts with just about the same code. Please restrict yourself to 1 post - we now have 3 seperate threads that deal with the same problem. this is extremely confusing. If you have additional questions about the same code/replies post them as replies in the same thread or update your OP (but if you do that, mark updates clearly so you don't make things even more confusing)

    Thanks.

      Good point. I would like to also suggest that he also put a discription of the problem and cthe code that he is posting before the post. In one of the posts the only mention of the problem is in the node name, then the body only contains code, which as you say is confusing. As a minor there was a total of 5 posts.

Re: problem in href and pagination
by john_oshea (Priest) on Dec 17, 2005 at 20:55 UTC

    If I'm reading that correctly, it sounds like you want something AJAX-y to dynamically update a single page without the user having to reload it. If that's the case then something like CGI::Ajax would probably be worth looking at.

    If you have a sufficiently small amount of data you could 'cheat' somewhat by loading all the data into a number of <DIV>s with all but one styled with visibility: hidden; and then use Javascript to show and hide them on the fly.

    Hope that helps

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://517481]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2014-08-20 05:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (105 votes), past polls