Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
仅当@Html.EditorFor等于“Make”时,“Make”按钮才触发Javascript;“已关闭”;_Javascript_Jquery_Html_Model View Controller - Fatal编程技术网

仅当@Html.EditorFor等于“Make”时,“Make”按钮才触发Javascript;“已关闭”;

仅当@Html.EditorFor等于“Make”时,“Make”按钮才触发Javascript;“已关闭”;,javascript,jquery,html,model-view-controller,Javascript,Jquery,Html,Model View Controller,在MVC web项目中,我在一个视图中有一个保存按钮,单击该按钮时调用javascript函数: 只有当状态下拉列表设置为选择“关闭”时,我如何使此按钮调用javascript函数 这是javascript function Confirm() { var input = $("<input />"); input.attr("type", "hidden").attr("name", "confirm_value"); if (confirm("Do you want t

在MVC web项目中,我在一个视图中有一个保存按钮,单击该按钮时调用javascript函数:

只有当状态下拉列表设置为选择“关闭”时,我如何使此按钮调用javascript函数

这是javascript

function Confirm() {
var input = $("<input />");
input.attr("type", "hidden").attr("name", "confirm_value");
    if (confirm("Do you want to save the ticket to the knowledge base archive?")) {
        input.val("Yes");
    } 
    else {
        input.val("No");
    }
$("form")[0].appendChild(input[0]);
}
函数确认(){
变量输入=$(“”);
input.attr(“type”,“hidden”).attr(“name”,“confirm_value”);
如果(确认(“是否要将记录单保存到知识库存档?”){
输入。val(“是”);
} 
否则{
输入值(“否”);
}
$(“表单”)[0].appendChild(输入[0]);
}
这是下拉列表的HTML代码:

@Html.LabelFor(model=>model.vcStatus,htmlAttributes:new{@class=“control label col-md-2”})
@Html.DropDownListFor(m=>m.vcStatus,Model.StatusList)
@Html.ValidationMessageFor(model=>model.vcStatus,“,new{@class=“text danger”})


非常感谢您的帮助。

您可以在“保存”按钮上调用javascript方法,并在javascript函数中检查下拉列表的状态