Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript within CGI, onClick events

    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:
    Code:
    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?
    Last edited by sudsey; 04-20-2009 at 01:44 PM. Reason: grammer mistake

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,944
    Thanks
    2
    Thanked 170 Times in 165 Posts
    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?

  • #3
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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,

  • #4
    Senior Coder
    Join Date
    Mar 2006
    Posts
    1,274
    Thanks
    2
    Thanked 39 Times in 38 Posts
    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?

  • #5
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, it doesn't. It's serverside. Don't Worry problem solved.

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by sudsey View Post
    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,
    Quote Originally Posted by sudsey View Post
    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

  • #7
    Senior Coder
    Join Date
    Mar 2006
    Posts
    1,274
    Thanks
    2
    Thanked 39 Times in 38 Posts
    Quote Originally Posted by sudsey View Post
    No, it doesn't. It's serverside. Don't Worry problem solved.
    If you say so.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •