Posted on 2006-06-08
Last Modified: 2008-02-26
Hi, I have an application to develop.
It'd be nice to do it in PERL only without JavaScript.

I know there's a way to do for a button but I need it for a table cell.

I have a table/grid of data, when user moves the cursor on top of a cell, the bgcolor lits up.
If they click on the cell, a "prompt" box pops up and user can enter an answer.
The grid along with the updated answer will then be saved to a file using PERL on UNIX.

The application is accessed via HTML, so when a picture is clicked, it calls my PERL script to dynamically generate the HTML with the JavaScripts, where JS takes care of the onMouseOver, onClick events. But the trouble came when I need to read the value from the onClick event (prompt box) from my PERL script.

How can I accomplish this?
Can PERL do similar thing like the JS events (onMouseOver, onClick, prompt box) so I can get rid of the JavaScript altogether?

Question by:chunich
    LVL 8

    Assisted Solution

    off the top of my head I am thinking this is not possible in the way you are hoping. Perl has nothing to do with the browser. Perl can't detect an onclick (or any event) that occurs in a browser window that I know of. Instead of using an onclick event you could use a hyper link or a CGI form  and pass data back to your perl script to do whatever it is you are wanting to do with the data.

    Maybe another expert has some better advice to offer so wait and see.
    LVL 18

    Expert Comment

    Perl is a server side language, ie it is parsed and run by the server.
    Javascript is client side language, ie it is parsed and run by your browser.

    To the best of my knowledge, there is no effective way to run perl "client side" in the browser.  I'm not entirely sure what you are trying to do.  Perhaps some code snippits might help?

    Author Comment


    In short, what I'm trying to accomplish is:

    - "abc.txt" is stored on UNIX server (it is a file with {date,name} in it)
    .... and so on

    - client access a webpage via browser, which reads from "abc.txt" and displays data in a table/grid format (calendar layout)
    - upon clicking on the target table cell (date), a prompt box displays the name as default and prompt user for a new name
    - user enters a new value (results not written back to file yet)
    - when [SUBMIT] button is clicked "abc.txt" is updated with the data user entered

    Basically it's an interface to update a schedule so people can be swapped in and out.

    The reason I use PERL is that I could not find ways to write to file on server via JavaScript (so what I heard).
    Any help/suggestion is greatly appreciated!!
    LVL 18

    Expert Comment

    "- upon clicking on the target table cell (date), a prompt box displays the name as default and prompt user for a new name"

    Is this a javascript prompt box?  Or are you using an html page to display this data?

    Author Comment

    Yea I am using a javascript prompt box to do so now.
    But the value cannot be seen from PERL.

    My structure is like:
    browser to ->
    it calls my PERL script

    then my PERL script fetch the file and prepares the HTML doc including the javascript stuff.

    So once user entered the new value in the prompt box my PERL has no way of know what it is since it's stored in the child/javascript variable (instead of my PERL variables).

    Now I'm trying to think of an alternative.
    If I declare 2 textboxes from PERL, JavaScript should be able to access them via, right?
    If user clicks on the table cell, I populate the date in it, and they can enter the name in the 2nd txtBox.
    Upon [SUBMIT], I use PERL to fetch and row in the file and updates it.

    Um... wonder if that'll work.
    LVL 18

    Expert Comment

    Why not just use an html box via javascript command to change the value.  You won't have to worry about passing variables back and forth, and you can customize the page to look much nicer than the default ugly javascript prompt.

    Author Comment

    Because I am relying on my PERL script to write data to file on the server.
    From JS prompt (or new window), I cannot go back to the parent PERL script to perform the file saving.

    Point A:

    Point B: HTML w/ JS

    Browser loads creates HTML w/ JS
    JS prompt box/HTML box
    *** now I have to get back to Point A (or call PERL func) to write the data back but I have no way of going back
    LVL 18

    Accepted Solution

    Browser loads creates html table based on abc.txt
    User clicks on link to bring up a small popup html window(
    Make changes in and click submit. submit to another script if you like) makes changes to abc.txt as needed.
    Small popup box has an onClose event.
    OnClose even fires window.parent.location.href = '' window is refreshed, and rereads the now changed abc.txt.

    This is a "simple" way of doing it.  If you want it to be more dynamic, then you would have to use some AJAX.
    LVL 18

    Expert Comment

    Ooops.  Should be window.opener.location.href
    LVL 8

    Expert Comment

    yea, everything Morcalavin said... :)

    Assisted Solution

    If you're doing it just for yourself, or you have some control over your clients using it, you might try PerlScript.  The browser user needs to have ActivePerl installed.

    Another alternative is to use XMLHttpRequest to send the information to your perl script in the background (considered Ajax).  It's a lot easier than I expected when I first started working with it.  Let me know if you want to go this route.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    sort hash by values desc 2 165
    hard perl script 16 137
    Excel to CSV conversion with specific columns 5 59
    Perl Awk Need Help 3 85
    Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
    Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now