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

I have a perl script that use cgi module. i use print $query->startform(action=>"http://127.0.0.1/cgi-bin/mycgi.cgi"); I want to change my action form during my script, but it is not possible becuase form construct and i can't use $query->form(action ... again , i heard we can change change form action before submit click by %FORM. is it posible , and are there any way to sole this proble thanks for ur help
  • Comment on changing Form Action before submit click

Replies are listed 'Best First'.
Re: changing Form Action before submit click
by Abigail-II (Bishop) on Mar 10, 2004 at 15:22 UTC
    Not sure what your real question is, but the obvious solution seems to be to determine what action you want to do, before calling startform.

    Abigail

Re: changing Form Action before submit click
by UnderMine (Friar) on Mar 10, 2004 at 15:36 UTC
    This seams more of a JavaScript issue. If I understand you use some javaScript that changes the action to a new target URL.

    A couple of type=button and javascript onClick could do this.

    Hope it helps
    UnderMine

Re: changing Form Action before submit click
by castaway (Parson) on Mar 10, 2004 at 15:36 UTC
    Once you have called the print command, to output something, you can't undo that, or take it back. So what you would need to to is not print at that point, but just save all the stuff to be printed until the end of the processing, and then do it.

    If you posted your script, and where exactly the problem is, we could be more specific with answers.

    C.

Re: changing Form Action before submit click
by fraktalisman (Hermit) on Mar 10, 2004 at 22:59 UTC
    sounds to me like it's best done in JavaScript, like:

    <form name="f1" action="subscribe.pl">
    <input type="radio" onClick="document.f1.action='subscribe.pl'"> Subscribe to the newsletter
    <input type="radio" onClick="document.f1.action='unsubscribe.pl'"> Unsubscribe
    (...)
    </form>
Re: changing Form Action before submit click
by neniro (Priest) on Mar 10, 2004 at 16:20 UTC
    You can try to use a templatesystem like HTML::Template. You can use alternative actions based on conditions in your script.
    neniro