我有两张这样的桌子:
类别 {categoryId, categoryName}
新闻 {newsId, newsTitle, categoryId}
在我的 asp.net mvc 项目中,我有一个视图:
<script type="text/javascript" src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(
function ()
{
$("#slCategory").change(
function ()
{
var value = $(this).val();
if (value == "All")
location.href = "GetAllByCategory";
else
location.href = "GetAllByCategory/?category=" + value;
}
);
}
);
</script>
<h2>Get All By Category</h2>
Select Category
<select name="slCategory" id="slCategory">
<option value="All">All</option>
<option value="1">Sport</option>
<option value="2">Social</option>
<option value="3">Economy</option>
</select>
@foreach (var item in Model)
{
<p>@item.newsTitle</p>
}
这不工作!
如何使用更改事件在选定类别中显示新闻?