jquery问题。。。自动提交表单并进入下一步的方法?

jquery问题。。。自动提交表单并进入下一步的方法?,jquery,forms,submit,Jquery,Forms,Submit,基本上,我有一个被分解成4种形式的过程(因此,4个URL),但我想完全绕过第三种形式。我无法真正了解代码本身,因为它来自第三方提供商,而不是开源。我希望做的是使用jquery在用户进入第三步时自动填写并提交表单,并且快速/自动完成,页面本身几乎看不见。。。这样做可行吗 所以,这里有一个简化的过程分解 STEP ONE: http://sample.com/step1.aspx <form name="step1"> <input type="text" name="stepo

基本上,我有一个被分解成4种形式的过程(因此,4个URL),但我想完全绕过第三种形式。我无法真正了解代码本身,因为它来自第三方提供商,而不是开源。我希望做的是使用jquery在用户进入第三步时自动填写并提交表单,并且快速/自动完成,页面本身几乎看不见。。。这样做可行吗

所以,这里有一个简化的过程分解

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>
第一步:http://sample.com/step1.aspx
第二步:http://sample.com/step2.aspx
第三步:http://sample.com/step3.aspx
(这是我想填写并自动提交的表格。。。
基本上,我想模拟用户按下“同意”按钮)
第四步:http://sample.com/step4.aspx

首先,不要对单个表单使用两个提交按钮,例如:

不要使用:

<form name="step3">
  <input type="submit" name="stepthreeagree" value="Agree" />
  <input type="submit" name="stepthreedisagree" value="Disagree" />
</form>
<form name="step3" action="http://sample.com/step3.aspx">
  <input type="radio" name="agree" value="agree" checked="checked" />
  <input type="radio" name="agree" value="disagree" />
  <input type="submit" name="stepthreeagree" value="Submit" />
</form>

使用:

<form name="step3">
  <input type="submit" name="stepthreeagree" value="Agree" />
  <input type="submit" name="stepthreedisagree" value="Disagree" />
</form>
<form name="step3" action="http://sample.com/step3.aspx">
  <input type="radio" name="agree" value="agree" checked="checked" />
  <input type="radio" name="agree" value="disagree" />
  <input type="submit" name="stepthreeagree" value="Submit" />
</form>

现在,由于已选中“同意”按钮,您可以按如下方式自动提交表单:

<script>
window.onload = function()
{
  document.step3.submit();
};
</script>

window.onload=函数()
{
document.step3.submit();
};
您可以
jQuery('input[name=steptreeagree]')。触发('click')。
如果表单DOM可用

或者,您可以尝试使用适当的数据发布/访问该位置。即

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

但是,通常情况下,这些多步骤表单以菊花链的形式链接数据(通过会话或隐藏输入),因此此解决方案可能不够充分

只是一个评论:听起来你在做一些粗略的事情。这里有一个很好的理论问题,但是为什么你要绕过别人的协议形式呢


Sarfraz:多个提交按钮有效。被单击的是其值已提交的。不确定这是规范,还是PHP的情况。

您能将JavaScript添加到所有页面吗

如果是这样,在
step2.aspx
中,您可以覆盖表单的提交,在AJAX中提交表单,然后定期提交第三个表单(例如,将
添加到页面,使用jQuery提交表单)

这样
step3.aspx
甚至不会闪烁


即使存在某种CSRF保护,您也可以从对AJAX提交的响应中grep CSRF保护字段。

我真的没有隐瞒。。。我保证。这是我们的协议形式,第三方已经包括在整个过程中,但从未提供摆脱它的方法。这是一个多余的步骤,因为他们必须在注册期间同意TOS。除非他们注册,否则他们甚至无法进入这个过程。这是第三方开发人员的疏忽,虽然他们正在“制定解决方案”,但我们仍然需要它以我们想要的方式运行…@snarkyosnarkers:只需将您的step 3表单替换为我用粗体文本编写的表单,最后将我上面编写的脚本添加到您的文件末尾。谢谢,我不知道如何解释我不能修改这个页面的html,但是说,我不能修改这个页面的html。否则,我会照你说的做。。。但是,同样,我不能修改这个页面的html。