Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/386.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
如何通过actionLink调用javascript函数_Javascript_Asp.net Mvc 3 - Fatal编程技术网

如何通过actionLink调用javascript函数

如何通过actionLink调用javascript函数,javascript,asp.net-mvc-3,Javascript,Asp.net Mvc 3,我无法通过asp.net mvc中的actionlink按钮调用javascript函数 submitForm()是我的函数 我的密码是-: <script type="text/javascript"> function submitForm(state) { if (state != "") { var ele = document.frmuser.elements; var

我无法通过asp.net mvc中的actionlink按钮调用javascript函数 submitForm()是我的函数 我的密码是-:

 <script type="text/javascript">
        function submitForm(state) {

           if (state != "") {
                var ele = document.frmuser.elements;
                var strvalue = "";

                for (var i = 0; i < ele.length; i++) {

                    if (ele[i].type == "checkbox") {
                        if (ele[i].name == "chkactive[]") {
                            if (ele[i].checked == true) {
                                //var a = ele[i].value; alert(a);
                                if (strvalue != "")
                                    strvalue = strvalue + "," + ele[i].value;
                                else
                                    strvalue = ele[i].value;

                            }
                        }
                    }
                }
                alert(strvalue);
                    if(strvalue != "" && state !="")
                    {
                        //alert(strvalue);
                        if (state == "active") {
                            location.href = '<%=Url.Action("Deletechkuser")%>' + '/' + $('select[name=chkactive[]]').val();
                        }
                        if(state == "deactive")
                        {
                            location.href = '<%: Url.Action("Deletechkuser", "Home" )%>doctors/updateStatus/' + strvalue + '/is_active/N/' + document.getElementById('hdcurpage').value + '/' + document.getElementById('hdsortkey').value + '/' + document.getElementById('hdsortdir').value;
                        }
                        if(state == "delete")
                        {
                            location.href = '<%: Url.Action("Deletechkuser", "Home" )%>' + strvalue + '/is_deleted/Y/' + document.getElementById('hdcurpage').value + '/' + document.getElementById('hdsortkey').value + '/' + document.getElementById('hdsortdir').value;
                        }
                    }
                    else
                        {
                        alert('Please Select Atleast One Record');
                        document.getElementById("actions").options[0].selected=true;        
                        }
            }
        }
    </script>
<button class="deletebutton radius3"  id="delete" onclick="location.href='<%: Url.Action("Deletechkuser", "Home", new { id= submitForm(this.id);} )%>'">
          delete</button> 

我找不到这条线:

我想传递所有的选择值,它在标准值中计数,进入控制器我是什么我不知道

如果要在单击ActionLink时调用
javascript
函数,则应订阅
onclick
事件

@Html.ActionLink("Link Text","ActionName","ControllerName",new { @onclick="MyFunction();" },null)
以下是脚本:

<script type="text/javascript">
    function MyFunction(){
        //Do something
        alert('Hello world');
    }
</script>

函数MyFunction(){
//做点什么
警报(“你好世界”);
}
希望能有帮助