...

View Full Version : Javascript within CGI, onClick events



sudsey
04-20-2009, 01:35 AM
Hi I'm writing a CGI script that creats a HTML page. On the buttons the CGI script creates I need to invoke a function in the OnClick event. I need to call one function multiple times however I get the error " ')' expected " but the calling of the function works from the onclick event when I call it once. Here's the code that causes the error:


while (fgets(pref, 5, fp)) {
getc(fp); // space
fgets(ptype, 4, fp);
getc(fp); // space
fgets(pname, 56, fp);
getc(fp); // space
fgets(price, 7, fp);
getc(fp); // space
fgets(delay, 4, fp);
getc(fp); // space
fgets(stock, 4, fp);
getc(fp); // space
fgets(altref, 5, fp);
fgets(line, 80, fp); // trailing spaces and newline char
printf("<tr>");
printf("<td>"); printf(pname);
printf("<td>"); printf(ptype);
printf("<td>"); printf("");printf(price);
printf("<td>"); printf("<input type='Button'id=%i value='View' align='middle' onclick='cat2(); cat(%s); cat(%s); cat(%s); cat(%s); cat(%s); cat(%s); cat(%s); cat1();'>", temp, pref, pname, ptype, price, stock, delay, altref);
printf("</td>");
printf("</tr>");
temp++;
}

The function I need to call mutilple times is cat(%s), is my syntax wrong?

FishMonger
04-20-2009, 05:09 PM
sudsey,

You posted your question in the Perl forum, but that's not Perl code. Did you mean to post it in the php or Javascript forum?

sudsey
04-20-2009, 07:05 PM
I'm sorry but I thought this was perl/CGI?
My code is javascript embedded in CGI, hence why the code has to be within Printf statements,

KevinADC
04-20-2009, 07:41 PM
Its still a javascript question. Perl can only generate the document that the javascript is embedded in, like an html document. But it has nothing to do with execution of the javascript, whcih is the browsers responsibility. It would only be a perl/CGI question if the perl code was having a problem. Does the javascript work if you just copy and paste it into a static html page?

sudsey
04-21-2009, 11:54 AM
No, it doesn't. It's serverside. Don't Worry problem solved.

oesxyl
04-21-2009, 02:07 PM
I'm sorry but I thought this was perl/CGI?
My code is javascript embedded in CGI, hence why the code has to be within Printf statements,


No, it doesn't. It's serverside. Don't Worry problem solved.
you don't know what language is but is solved? that's weird.

regards

KevinADC
04-21-2009, 06:06 PM
No, it doesn't. It's serverside. Don't Worry problem solved.

If you say so. :confused:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum