Jquery question… a way to automatically submit a form and move to the next step

formsjquerysubmit

Basically, I have a process that is broken out into 4 forms (thus, 4 urls), but I'd like to bypass the third one completely. I can't really get to the code itself as it's from a third party provider and not open-source. What I was hoping to do was to use jquery to automatically fill out and submit the form as soon as the user gets to that third step, and do it so quickly / automatically, that the page itself is virtually unseen… Is something like that doable?

So, here's a simplified breakdown of the process…

STEP ONE: http://sample.com/step1.aspx

<form name="step1">
<input type="text" name="stepone" value="" />
<input type="submit" name="steponesubmit" value="Submit" />
</form>

STEP TWO: http://sample.com/step2.aspx
<form name="step2">
<input type="text" name="steptwo" value="" />
<input type="submit" name="steptwosubmit" value="Submit" />
</form>


STEP THREE: http://sample.com/step3.aspx
(This is the one I'd like to fill out and submit automatically... 
 Basically, I want to mimic the user having pressed the "Agree" button)
<form name="step3">
<input type="submit" name="stepthreeagree" value="Agree" />
<input type="submit" name="stepthreedisagree" value="Disagree" />
</form>

STEP FOUR: http://sample.com/step4.aspx
<form name="step4">
<input type="text" name="stepfour" value="" />
<input type="submit" name="stepfoursubmit" value="Submit" />
</form>

Best Solution

You can jQuery('input[name=stepthreeagree]').trigger('click'). If the form DOM is available.

Or you can try posting/getting to the location with the appropriate data. I.E

jQuery.post('blahblah.html',{ stepthreeagree: 'Agree' })

Often times though, these multi-step forms daisy chain their data (either through sessions or hidden inputs) so this solution might be insufficient.

Just a comment: it kind of sounds like you're doing something sketchy. There's a good theoretical question here, but why are you trying to bypass someone's agreement form?

Sarfraz: multiple submit buttons are valid. The one that gets clicked is the one whose value is submitted. Not sure if this is spec, or just the case for PHP.