经典的asp多按钮点击

时间:2012-12-11 12:36:44

标签: asp-classic

我有2个asp页面。

  • Feedback_Administration_Update.asp
  • Feedback_Administration.asp

我的HTML表单:

<form ACTION="Feedback_Administration_Update.asp" METHOD=POST NAME="form">
  <input type="button" value="Submit" onclick="javascript:Checkit();" name="btnSubmit">
  <input type="reset" value="Reset" onclick="javascript:document.location=location">
  <input type="button" value="Send Response to Requester" name="btnSubmit" onclick="javascript:Checkit();"/>
</form>

Feedback_Administration_Update.asp文件中的代码:

dim buttonPressed
buttonPressed=Request.Form("btnSubmit")
select case buttonPressed
    case "Submit"
        'update database code 
        Response.Redirect "feedback_administration.asp?ID=" & regEx.Replace((request.form("ID")), "''") & "&lstPages=" & Trim(Request("lstPages")) & "&view=" & Request("view")& "&strSuccess1=" &"Success"
    case "Send Response to Requester"
        'mail  task code 
End Select

我不确定他们为什么不点击任何按钮。

当我点击提交页面时,它应该更新代码,当我点击提交发送响应给请求者时,它应该发送电子邮件。

1 个答案:

答案 0 :(得分:1)

按钮输入的值不会发送到服务器。您需要使用普通的提交按钮,并且要获得验证码,您可以取消他们的onclick事件:

<input type="submit" value="Submit" onclick="return Checkit();" name="btnSubmit" />
<input type="submit" value="Send Response to Requester" name="btnSubmit" onclick="return Checkit();" />

要使其工作,请以两种方式更改JavaScript函数。首先,不要让它提交表单,然后在成功验证后返回true,否则返回false,例如:

function Checkit() {
    //validate your stuff..
    if ([all is good]) {
        //don't submit the form here, the submit button will do that.
        return true;
    }

    //indicate that something was wrong, cancel form submission:
    return false;
}

实现此目的将使Request.Form("btnSubmit")保持所需的值。