in reply to Re: Link instead of Submit button?
in thread Link instead of Submit button?

Hi perl_lover,

Thanks for your prompt response.

I copied & pasted the substitution you suggested, but I can't get it to work.  When I click the "Submit" link, it seems to do nothing, except append the URL with "#".

Here's the expanded HTML of the original form (from Firefox's Page Source option):

<form method="post" action="/cookie_test/cookie1.pl" enctype="applicat +ion/x-www-form-urlencoded"> <input type="hidden" name="_logout" value="1" /><input type="submit" +name="Log out" value="Log out" /></form>

And here's yours:

<form method="post" action="/cookie_test/cookie2.pl" enctype="applicat +ion/x-www-form-urlencoded"> <input type="hidden" name="_logout" value="1" /><a onclick="document. +forms[1].submit()" href="#">Submit</a></form>

Any ideas what's going wrong?

Replies are listed 'Best First'.
Re^3: Link instead of Submit button?
by Corion (Patriarch) on Dec 17, 2010 at 09:32 UTC

    This is a simple HTML issue that you can debug yourself. Perl is only very remotely involved, as it generates the HTML.

    I suggest that you first debug your HTML issue by finding out what HTML needs to be generated, and only as a second step, add the necessary print statements to your script that print the HTML.

      Point taken, Corion.

      Thanks.

Re^3: Link instead of Submit button?
by perl_lover (Chaplain) on Dec 17, 2010 at 10:21 UTC
    In your example there is only one form. Use this piece. It should work.
    print startform, hidden("_logout", 1),a({-href=>'#',-onClick=>"documen +t.forms[0].submit()"},"Submit"), endform;


    use Perl;
    Perl4Everything

      Thanks perl_lover.  That works.

      Although I'll probably go with Corion's non-JavaScript solution in this case, I was interested to see how your solution was done, lest a need for that kind of think comes up in future.

      Thanks.