in reply to POSTing with LWP::UserAgent

Here's an example for you, that works OK, except for a bug that I need help with. the POST is here, and the form is below. The thing is, I can't get it to set the checkbox values and I can't find any doc anywhere to tell me how. I did this working from Orwant & Gruhl's article in TPJ 4:1. Any help would be a godsend!
sub getLinkParse { use LWP::UserAgent; use HTTP::Request::Common; $sentence = "This is a test sentence."; $response = (new LWP::UserAgent)->request(POST 'http://www.link.cs.cmu.edu/cgi-bin/link1/construct-page-4 +.cgi#submit', [ Sentence => $sentence, Constituents => "1", <<<< this is a checkbox NullLinks => "1", <<<< this is a checkbox AllLinkages => "OFF", LinkDisplay => "on", ShortLength => "6", PageFile => "/docs/submit-sentence-4.html", InputFile => "/scripts/input-to-parser", Maintainer => "sleator\@cs.cmu.edu" ] ); exit -1 unless $response->is_success; $_ = $response->{_content}; print $_; } This is the origianl form on the site: <FORM METHOD="POST" ACTION="/cgi-bin/link1/construct-page-4.cgi#submit +"> <textarea name="Sentence" MAXLENGTH=200 wrap=virtual rows=3 cols=70>< +/textarea><br> <INPUT TYPE="checkbox" NAME="Constituents" CHECKED>Show constituent tr +ee &nbsp; <INPUT TYPE="checkbox" NAME="NullLinks" CHECKED>Allow null links &nbsp +; <INPUT TYPE="checkbox" NAME="AllLinkages" OFF>Show all linkages &nbsp; <INPUT TYPE="HIDDEN" NAME="LinkDisplay" VALUE="on"> <INPUT TYPE="HIDDEN" NAME="ShortLength" VALUE="6"> <INPUT TYPE="HIDDEN" NAME="PageFile" VALUE="/docs/submit-sentence-4.ht +ml"> <INPUT TYPE="HIDDEN" NAME="InputFile" VALUE="/scripts/input-to-parser" +> <INPUT TYPE="HIDDEN" NAME="Maintainer" VALUE="sleator@cs.cmu.edu"> <br> <INPUT TYPE="submit" VALUE="Submit one sentence"> <br> </FORM>

Replies are listed 'Best First'.
Re: Re: POSTing with LWP::UserAgent
by chromatic (Archbishop) on Jan 08, 2001 at 10:18 UTC
    Checkboxes without explicit VALUE fields return "ON". At least, in web browsers that follow the specifications. :)

    Try that instead of "1".

      Thanks for the suggestion re checkboxes. I tried "ON", "CHECKED", "1", "Dammit" -- none of them worked. In general, where can I find more information about this? I'm sure my next problem will have radio buttons or something else I don't know how to do! ...
        I suggest you may want to save the form to disk and change the form action url to point to a cgi that does nothing but display its parameters ( a useful thing to have sometimes, and trivial to write ). Then open the form in the browser usually used, and submit the form, then look at what is being passed for the checkboxes in the query.