TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mahesh Bodepudi
NA
90
56.9k
JavaScript runtime error: 'YearChange' is undefined
Nov 29 2016 6:39 AM
Hi,
I am working with MVC4
In this my controller code is like this
public JsonResult GetMonthByYear(int Year)
{
var lst = PODb.orders.Where(x => x.Year == Year).Distinct().ToList().FirstOrDefault();
long lnSupName = Convert.ToInt64(Year);
po po = PODb.poes.Where(x => x.ID == lnSupName).FirstOrDefault();
string strSupplierPhno = PODb.poes.Where(x => x.ID == po.ID).Select(c => c.OfficePhoneNo).FirstOrDefault();
string strContactPerson = PODb.poes.Where(x => x.ID == po.ID).Select(c => c.Contacts).FirstOrDefault();
return Json(new { suplierPhnNo = strSupplierPhno, contactName = strContactPerson });
}
I have written the below code in my view
function YearChange() {
alert("strsupName");
var strsupName = $('#Year_ID').val();
if ((strsupName) != "")
{
alert(strsupName);
var options = {};
options.url = "/PO/GetMonthByYear";
options.type = "POST";
options.dataType = "json";
options.data = { Year: $("#Year_ID").val() };
options.success = function (result) {
var Text_PhnNumber = result.;
document.getElementById("txtSupplierPhnId").value = Text_PhnNumber;
var Text_ContactPerson = result.contactName;
document.getElementById("txtcontactId").value = Text_ContactPerson;
}
$.ajax(options);
}
}
@Html.DropDownListFor(x => x.Year,(IEnumerable<SelectListItem>)ViewData["Year"], "Year", new {Id = "Year_ID", @onchange = "return YearChange();" })
with the above code I want to populate another Months dropdown when particular year is changed.
I am getting the below exception
JavaScript runtime error: 'YearChange' is undefined
Also i added the below references
<script src='http://code.jquery.com/jquery-latest.min.js' type='text/javascript'></script>
<script src="~/js/jquery.js"></script>
<link href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.min.js">
</script>
Please help on this
Reply
Answers (
2
)
How two different solutions can communicate.
error - Connecting MySQL to EF 6 in Visual Studio 2012