Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Using javascript in CGI C script

    I want to call a javascript function from cgi c script.
    I have this in my html header part,
    printf("<script type=\"text/javascript\" src=\"/cgi-bin/test.js\">");

    And in the body,
    printf("<input type=\"button\" id= \"Btn\" name=\"Button\" value=\"Set\" onclick=\"SetValue();\" size=\"4\">");

    In test.js,
    function SetValue()
    alert('button clicked');

    I don't get the alert message. However if i call alert directly in button onclick without javascript, i get the alert message. How do i get the javascript to work?

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Nottingham, England
    Javascript is normally executed on the client, while CGI is server-side. Are you sure you want to do this? If you're doing things server-side, surely you should be executing PHP or Perl scripts directly, not code embedded into your web page - which is for the client to use.
    Linux user #126863 - see

Posting Permissions

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