http://qs1969.pair.com?node_id=1157568

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

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(); }