Link to home
Start Free TrialLog in
Avatar of chunich
chunich

asked on

PERFORM AN onClick EVENT IN A HTML TABLE CELL USING PERL?

Hi, I have an application to develop.
It'd be nice to do it in PERL only without JavaScript.

IS THERE A WAY TO PERFORM AN onClick EVENT IN A TABLE CELL USING PERL?
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?

Thanks.
SOLUTION
Avatar of Perl_Diver
Perl_Diver

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
Avatar of chunich
chunich

ASKER

Hello,

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)
sample:
06/01/2006,Angel
06/02/2006,Billy
06/03/2006,Cindy
.... 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!!
"- 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?
Avatar of chunich

ASKER

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 -> http://xxx.xxx.com/application/
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 document.form.xxx, 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.
Why not just use an html box via window.open 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.
Avatar of chunich

ASKER

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: test.pl

Point B: HTML w/ JS

Browser loads test.pl
test.pl 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
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ooops.  Should be window.opener.location.href
yea, everything Morcalavin said... :)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial