I'm using Mojo::UserAgent to access the form here. But rather than an html button, the form submission widget is wired to some javascript like so:

<div class="btn1" id="VALIDBTN" onclick="validate()">Submit</div>

intending to trigger this code:

function validate(){
	submitFlag = true;
	validateFirstName();
	validateLastName();
	validateTown();
	validateDOB();
	if(submitFlag){
		$('#form1').attr('method', 'POST');
		$('#form1').attr('action', '/MVP/voterDetails.do');
		$('#currentSearch').val("1");
		$('#countyName').val($("#county").find("option:selected").text());
		submitForm();		
	}else{
		return false;
	}
}

So far, what I have looks like this:

sub validate_signature {
  my $signature = shift;
  my $base_url = 'https://www.mvp.sos.ga.gov/MVP/mvp.do';
  my %data = (
        firstName => $signature->{'sig_fname'},
         lastName => $signature->{'sig_lname'},
           county => $signature->{'sig_county'},
              dob => $signature->{'sig_dob'},
    currentSearch => 1,
  );
  my $tx = $ua->get( $base_url => \%data );
  print Dumper $tx;
}

Attempts to POST this data yield: "405 - HTTP verb used to access this page is not allowed." and my GET requests get the html of the form, not the results of the javascript function and its POST back to its source.

Curious to know if there is a way to trigger this onclick somehow. Joel Berger's Mojo::Phantom looks interesting and useful but does not seem to do quite what I'm looking for. Any ideas would be welcome.

-- Hugh

if( $lal && $lol ) { $life++; }
if( $insurance->rationing() ) { $people->die(); }

In reply to Possible to Trigger js function with Mojo::UserAgent? by hesco

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.