Mvc Razor从DDL到Actionlink的脚本编写

Don*_*yle 2 asp.net-mvc razor

Vs'12 Asp.net C#MVC4,Internet Application Tempalte

我正在尝试<script>为我的下拉列表编写一个更改actionlink的信息.

我有什么安慰

 function select_prospect() {
    //Handle the select event

    $('#YourActionLinkName')val() = $("#Prospects").val();

    var val = $("#Clients").val();
    var href = "/Prospect/Index/" + val;
    this.href = ""; //clears out old href for reuse
    this.href = href; //changes href value to currently slected dropdown value
}
Run Code Online (Sandbox Code Playgroud)

我试图通过ID/Name抓取我的Actionlink,然后更改其值并添加相应的href与下拉列表中的那些.我究竟做错了什么?

编辑:

根据Ufuks的回答,我尝试了这段代码

$('#YourActionLinkName').val(
  $("#Prospects").val(),
  this.href = "/Prospect/Create/" + $("#Prospects").val()
);
Run Code Online (Sandbox Code Playgroud)

在<script>页面底部仍然没有正确更新我的actionlink.想法?

Ufu*_*arı 5

这不是您使用该val功能的方式

$('#YourActionLinkName').val() = $("#Prospects").val();
Run Code Online (Sandbox Code Playgroud)

它应该是这样的:

$('#YourActionLinkName').val($("#Prospects").val());
Run Code Online (Sandbox Code Playgroud)