1
如果驗證通過,我使用以下代碼發送POST請求。但事實並非如此。有人能告訴我一個方法使其工作。通過javascript中的函數發送POST
<script type="text/javascript">
function go()
{
var username = document.form.name.value;
var pwd = document.form.pwd.value;
if (username == '') {
var oldHTML = document.getElementById('myAnchor').innerHTML="Please fill out username.";
var newHTML = "<span style='color:red'>" + oldHTML + "</span>";
document.getElementById('myAnchor').innerHTML = newHTML;
}
if (pwd == '') {
var oldHTML = document.getElementById('myAnchor2').innerHTML="Please fill out password.";
var newHTML = "<span style='color:red'>" + oldHTML + "</span>";
document.getElementById('myAnchor2').innerHTML = newHTML;
}
else {
document.form.method="POST";
document.form.action = "data.php";
}
</script>