Closed Thread
Results 1 to 4 of 4

Thread: How I can execute Javascript into Perl?

  1. #1
    tony.willson is offline Newbie
    Join Date
    Nov 2007
    Posts
    3
    Rep Power
    0

    How I can execute Javascript into Perl?

    I don't know how I can execute an event of Javascript into a link in a program in Perl.
    This event of JavaScript have executed a function that return a HTML page.
    Anybody know how I can it?

    Is it possible do it this?:
    $datos=$datos.""<a>"";

    What is bad in this code?

    Thank you very much.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    KevinADC is offline Programmer
    Join Date
    Jan 2007
    Posts
    125
    Rep Power
    0
    I may not understand your question, but you can't execute javascript in perl code. Maybe you can look into AJAX.

  4. #3
    fahlyn's Avatar
    fahlyn is offline Learning Programmer
    Join Date
    Nov 2007
    Posts
    35
    Rep Power
    0
    Your question doesn't make sense at all. I think there are a few things you need to understand first.

    1. JavaScript is executed on the client - in the browser after the page has been rendered.
    2. Perl is executed on the server to either create a document to send to the client or to accept something submitted from the client (like a form being submitted or a link being clicked).


    There is a complete separation between JavaScript and Perl, you can't execute one from the other. You can use Perl to generate JavaScript and send it to the client to be executed...or you can use JavaScript to send an HTTP request to the server to execute Perl and return a reply (HTML, XML, JSON or text) to the JavaScript that sent the HTTP request (this is Ajax which Kevin mentioned).

    Again, I've got no idea what you're asking - can you maybe try to re-work your question or post more than just one line of code?
    Visit My Google Group Here: Web Development Innovation

  5. #4
    jonmacpherson is offline Newbie
    Join Date
    Dec 2007
    Posts
    7
    Rep Power
    0

    Wink

    Quote Originally Posted by tony.willson View Post
    I don't know how I can execute an event of Javascript into a link in a program in Perl.
    This event of JavaScript have executed a function that return a HTML page.
    Anybody know how I can it?

    Is it possible do it this?:
    $datos=$datos.""<a>"";

    What is bad in this code?

    Thank you very much.

    Well, The first thing that jumps out at me is the string. The code should look like this:

    $datos = $datos . "\"<a>\"";

    You have to use the \ (escape character) to send a " (double quote) character from a " double qouted string.
    You could also write the code as follows:

    $datos = $datos . '"<a>"'; # Note the use of single qoutes.

    As far as writing javascript in perl, here is how you could send javascript to the client, from perl:

    print "<script type=\"text/javascript\">";
    print "var one = 1;";
    print "var two = 3;";
    print "</script>";

    but that is just javascript output, not actually javascript being executed in perl. I do not think there is a way to directly introduce javascript code in perl.

    You may be able to write a seperate javascript program, and somehow run a system call to execute it....

    system(" dos/linux command ");

    But thats all I can think of.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Can't execute query
    By happy in forum PHP Development
    Replies: 5
    Last Post: 08-22-2009, 11:42 AM
  2. else statement will not execute?
    By zeroradius in forum PHP Development
    Replies: 6
    Last Post: 07-30-2009, 02:07 PM
  3. Can't execute query
    By happy in forum PHP Development
    Replies: 7
    Last Post: 07-17-2009, 09:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

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