我如何提交表单,并在同一时间移动到下一页
How can i submit form and move to the next page both at a time?
我的HTML代码部分:
<form method="post" id="form">
<input type="number" min="0" max="20" id="experience" required name="experience"title="experience" class="formfield" />
<input type="image" id="registersubmit4" name="registersubmit4" src="images/arrow-right.png" title="next"/>
</form>
我想提交表单时,用户点击下一个和提交后,然后移动到下一页。
<input type="image">
可以很好地提交,但提交后我想移动到下一页。
我使用javascript onclick()事件如下:
<input type="image" onclick=form.submit(); "location='next.html'">
这不起作用。请帮助……
这通常通过在表单上指定一个操作来完成:
<form method="post" action="newpage.html" id="form">
…但是,如果处理表单的页面与您想要访问的页面不同,则可以使用服务器端重定向。如何工作将取决于您使用的服务器端语言。
我用这个来解决我的问题。
jQuery(window).attr("location", "your page or external link goes here");
看一下jQuery.post。你可以试试这样做。
<script>
// Attach a submit handler to the form
$( "#form" ).submit(function( event ) {
// Stop form from submitting normally
event.preventDefault();
// Get some values from elements on the page:
var $form = $( this ),
exp = $form.find( "input[name='experience']" ).val(),
url = $form.attr( "action" );
// Send the data using post
var posting = $.post({
url: url,
data: { experience: exp } );
success: function( data ) {
window.location='next.html';
}
});
});
</script>
相关文章:
- JS'加载'函数在同一时间调用
- jQuery 悬停/单击事件位于同一 DIV(移动设备)上
- 为什么 D3 折线图和条形图显示在同一时间
- DIV在页面加载时随计算机时间移动
- Date.getTime() 为同一时间戳提供两个不同的值
- 如何在同一时间内在每台设备上每30秒调用一次函数
- 切换视频源-滑块上的同一时间-JS,HTML5视频
- 如何在同一时间和同一鼠标事件上旋转两个不同的X3D场景
- 每天在同一时间开始
- HTML5JS在同一时间多次播放相同的声音
- js控制台和rails控制台在同一时间打印不同是否正常
- 如何使3张图片幻灯片在同一时间
- Jquery扩展和滚动在同一时间
- 显示文本时,按下按钮(多个按钮),但只有一个文本在同一时间
- 引导标签-点两个标签同一时间
- 调用同一函数的两个dom事件如果在同一时间发生,则应该只调用该函数一次
- CkEditor - 2种风格在同一时间…
- 我的js函数不能处理2调用在同一时间
- jQuery卷轴插件:移动两个卷轴在同一时间
- 我如何提交表单,并在同一时间移动到下一页