2013-02-13 145 views
0

我正在使用以下JavaScript提交表单,但它未提交。未提交HTML表单的Java脚本

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

的东西,你定义exercisenew? – 2013-02-13 06:02:13

+0

你的表单中没有任何内容,它会在哪里提交? – 2013-02-13 06:07:52

回答

0

创建exercisenew

var exercisenew = document.getElementById("exercisenew") 

对象,并尽一切你都做

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."); 
} 
+0

现在不行。我粘贴了更多的代码.. – 2013-02-13 06:24:01