Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

I have a web page with various headings on it, followed by a table.

When I press a certain button, I would like the original table to disappear, and be replaced by another table that my script will generate.

What I need is a command that will remove the original table.

There is probably some very simple way of doing this, but being a perl newbie, I don't seem to be able to find out what it is.

Could you please help me?

TIA,

CJ

Replies are listed 'Best First'.
Re: clearing a page
by Fletch (Bishop) on Jul 26, 2005 at 13:06 UTC

    Sounds like you want something AJAX-y, which means this isn't strictly a Perl question. Check out script.aculo.us for that route.

    The more portable non-Javascript thing to do though would be to just have a form that submits to another CGI (or the same one with an extra parameter) which makes it generate a new page with the new table.

    --
    We're looking for people in ATL

Re: clearing a page
by polettix (Vicar) on Jul 26, 2005 at 13:38 UTC
    [...] be replaced by another table that my script will generate
    Given that you're posting here in PM, I assume that you're talking about a Perl script. This script works on the server side, so if you need to do computation locally on the client side the suggestions given above by others should suffice.

    OTOH, if what you want to do is server side, all you have to do is to introduce a little logic inside your script. Basically, your script must cope with the generation of both the original page, and the target page. What table you have to display actually depends on what parameters the browser sent to the server, i.e. if the button was pressed.

    This kind of situations should be handled quite well by CGI::Application: for each possible "state", or "view", of your application, you can program an ad-hoc "run-mode". In this way, you can have the default run-mode display the first table, and program a dedicated run-mode to display the other table. You'll notice that the example provided in the documentation gives you three run-modes: one with a starting query form, one with a general table, one with the details for an entry of the intermediate table - this should be a fairly useful starting point.

    Anyway, this is only one of the possible ways. You can Super Search for stuff like CGI and templating systems, without forgetting to see in Tutorials and Categorized Questions and Answers as well.

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.
Re: clearing a page
by jeteve (Pilgrim) on Jul 26, 2005 at 13:05 UTC
    Hi ! It seems to be more a javascript than a perl question. You can generate both table at server side in perl and make the display switch between'em in javascript at client side.
    Nice photos of naked perl sources here !
Re: clearing a page
by xorl (Deacon) on Jul 26, 2005 at 17:33 UTC
    I think you want something like this JavaScript and CSS answer

    If you want to submit a form then do something with the data and display the results then perl might be the solution. I would look into CGI for this.