我有一个购物车页面。我想获取有关我的customter.i的信息,我有一个提交按钮
<input type="button" id="submit-cart" value='Submit' onclick="submit_cart()" />
我希望在提交表单onclick后重定向到新页面。
答案 0 :(得分:0)
使用window.location = url
重定向
所以这看起来像
function submit_cart() {
var url = 'xyz.com' // Some url you want to redirect to
window.location = url;
}
在php中,您可以使用header
函数执行此操作:
<?php
header('Location: xyz.com'); // xyz.com is the url you want to redirect to
exit();
?>
答案 1 :(得分:0)
function submit_cart () {
/* do something amazing you always wanted to do with the user's data */
window.location.assign('/* here comes the url the user should be sent to */');
}
或者,根本没有javascript:
<form action = "url to redirect to" method="<!-- POST / GET -->">
<input type="text" name="textinput"/>
<input type="submit" class="button" id="submit-cart" value='Submit'/>
</form>