我正在使用以下javascript提交表单,但它没有提交。
if(timeup)
{
alert("welcome to time up.");
var id = document.getElementById("test_id").value;
var no = document.getElementById("noq").value;
var action = 'result.php?id='+id+'&no='+no+'';
exercisenew.action = action;
alert("form"+exercisenew.action);
exercisenew.submit();
alert("form submitted.");
}
完整代码here。
Html表单。
<form method="post" action="" id="exercisenew" name="exercisenew">
答案 0 :(得分:1)
if(timeup)
{
alert("welcome to time up.");
var id = document.getElementById("test_id").value;
var no = document.getElementById("noq").value;
//use encodeURIComponent()
var action = encodeURIComponent('result.php?id='+id+'&no='+no+'');
//get the form
var exercisenew = document.getElementById("exercisenew")
exercisenew.action = action;
alert("form"+exercisenew.action);
exercisenew.submit();
alert("form submitted.");
}
答案 1 :(得分:0)
为exercisenew
var exercisenew = document.getElementById("exercisenew")
并完成你所做的所有事情