in reply to Counter problem

Is it always the same number of digits? E.g. 6?

Your HTML could look something like:

<IMG SRC="digit.pl?position=5" ><IMG SRC="digit.pl?position=4" ><IMG SRC="digit.pl?position=3" ><IMG SRC="digit.pl?position=2" ><IMG SRC="digit.pl?position=1" ><IMG SRC="digit.pl?position=0"

The > is at the beginning of the next line to prevent some browsers (e.g. Netscape) to insert whitespace between one digit and another.

Now all you have to do is:

For example if you dynamically generate the page, you could have something like:

<IMG SRC="digit.pl?position=5&session=foobar-id" ><IMG SRC="digit.pl?position=4&session=foobar-id" ><IMG SRC="digit.pl?position=3&session=foobar-id" ><IMG SRC="digit.pl?position=2&session=foobar-id" ><IMG SRC="digit.pl?position=1&session=foobar-id" ><IMG SRC="digit.pl?position=0&session=foobar-id"
or even (which is text browser friendly):
<IMG SRC="digit.pl?digit=0" ALT=0 ><IMG SRC="digit.pl?digit=0" ALT=0 ><IMG SRC="digit.pl?digit=1" ALT=1 ><IMG SRC="digit.pl?digit=9" ALT=9 ><IMG SRC="digit.pl?digit=7" ALT=7 ><IMG SRC="digit.pl?digit=3" ALT=3

Other possibilities include cookies.

This method makes it easy to glue together many images in your HTML, if it is dynamically generated, for example the result of a CGI. Otherwise digit.pl has to go through a god deal of work (presumably) to generate an progressive number for each visitor, which does not mean increase the counter every time digit.pl is called, not even every six times digit.pl is called, because basically you have no idea of what could happen.

So you may want to consider this solution if you dynamically generate your HTML, otherwise you require much more effort to make digit.pl work reliably for each digit and for each session/user.

-- TMTOWTDI

Replies are listed 'Best First'.
Re: Re: Counter problem
by thpfft (Chaplain) on Sep 01, 2001 at 04:01 UTC

    six cgi calls seems a little over the top for a counter. Any tag which results in a call back to the server will do. Iframes and layers are a bit picky, but how about:

    <script language="javascript" src="/cgi-bin/counter.pl"></script>

    and have the perl script check the referer and return a simple javascript? You could use it to change the .src of six images that already existed, or perhaps just document.write('123456'); would suffice.

    nb. remember it would be:

    print "Content-type:application/x-javascript\n\n";

    and not the usual text/html.