[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 770
  • Last Modified:

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.
0
chunich
Asked:
chunich
  • 5
  • 3
  • 2
  • +1
3 Solutions
 
Perl_DiverCommented:
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.
0
 
MorcalavinCommented:
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?
0
 
chunichAuthor Commented:
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!!
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
MorcalavinCommented:
"- 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?
0
 
chunichAuthor Commented:
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.
0
 
MorcalavinCommented:
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.
0
 
chunichAuthor Commented:
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
0
 
MorcalavinCommented:
Browser loads test.pl
test.pl creates html table based on abc.txt
User clicks on window.open link to bring up a small popup html window(test2.pl)
Make changes in test2.pl and click submit.
test2.pl(or 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 = 'test.pl'
test.pl 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.
0
 
MorcalavinCommented:
Ooops.  Should be window.opener.location.href
0
 
Perl_DiverCommented:
yea, everything Morcalavin said... :)
0
 
jfluhmannCommented:
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.

http://www.xav.com/perl/Components/Windows/PerlScript.html

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.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now