Click to See Complete Forum and Search --> : about CGI


wind0965
01-20-2004, 10:30 AM
The code is:

<script language=javascript type="text/javascript">
<!--
var countimg = 0;
function reloadImage()
{
var da = new Date();
if (document.imglive)
document.imglive.src = "/rec/img.cgi?" + countimg + "+out.jpg";
countimg ++;
delete da;
}
function reloadAfter()
{
window.setTimeout("reloadImage()", 1900);
}

function reloadCounter()
{
var da = new Date();
if (document.imgcounter)
document.imgcounter.src = "/rec/imgcnt_xxxxxxxx.cgi?" + countimg + "+out.bmp";
countimg ++;
delete da;
}
function reloadCounterAfter()
{
window.setTimeout("reloadCounter()", 1600);
}

function isLoaded() {
reloadImage();
reloadCounter();
}
// -->
</script>


What does "/rec/img.cgi?" + countimg + "+out.jpg" mean?
1. Why there is a "?" after .cgi?
2. What does the "+" mean?
3. Are the counting and "+out.jpg" parameters or something else?

I am not familiar with CGI, hope you may help me.
Thank you in advance!

garfvader
01-21-2004, 11:27 AM
In this case, let's look at that entire line.

document.imglive.src = "/rec/img.cgi?" + countimg + "+out.jpg";

If you've ever done say javascript or html, you know that src means source, so anything on the right side of the equals is going to be the source location of the file he's looking for.

/rec/img.cgi is the location of another cgi that this person is running, probably some sort of obviously image program. You'll notice there's a ? right after it. Anything to the right of a ? is basically data that's being sent to the cgi.

countimg is a variable. By doing this:
"/rec/img.cgi?" + countimg, you're appending countimg to the end of that string. So let's say countimg is a number like 4. This is telling the program to make the string instead:
/rec/img.cgi?4
Then by adding "+out.jpg" at the end, he completes the data that he's sending to the program.

Hehe was that confusing?