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
Ayush Patil
NA
178
20.5k
cascading dropdown
May 22 2018 6:43 AM
Hello Friendz,
In this session I am insert the user with some kind of details and update the details.
now my problem is that, when I am change the Zone value then State and branch value removed same case for update case. please see the image for reference.(Getting all value as per zone in state and branch)
now what I need that,when I change the value of zone then textbox will reset with its value i.e. Select State and same for branch
while in update case need same.
my code as below
Script:-
$('#ddlZone').on('change', function () {
var ZoneCode = $('#ddlZone option:selected').val();
debugger;
fillState(ZoneCode, -1);
});
// On State change event Branch Append
$('#ddlState').on('change', function () {
var StateCode = $('#ddlState option:selected').val();
debugger;
fillBranch(StateCode, -1);
});
function fillState(ZoneCode, StateCode) {
$('#ddlBranch option').remove;
$.ajax({
type: 'GET',
data: { ZoneCode: ZoneCode },
url: "/Admin/loadStates",
success: function (result) {
var s = '
Select State
';
for (var i = 0; i < result.length; i++) {
s += '
' + result[i].StateName + '
';
}
//if (StateCode.toString() != "0")
$('#ddlState').html(s);
$('#ddlState').val(StateCode);
}
});
}
function fillBranch(StateCode, BranchCode) {
$.ajax({
type: 'GET',
data: { StateCode: StateCode },
url: "/Admin/loadBranch",
success: function (result) {
var s = '
Select Branch
';
for (var i = 0; i < result.length; i++) {
s += '
' + result[i].BranchName + '
';
}
$('#ddlBranch').html(s);
// if (BranchCode.toString() != "0")
$('#ddlBranch').val(BranchCode);
}
});
}
HTML code:-
Zone
*
:
Select Zone
@foreach (var ZoneMaster in ViewBag.Zones) {
@ZoneMaster.ZoneName
}
State
*
:
Select State
Branch
*
:
Select Branch
Reply
Answers (
2
)
Javascript [Radio button]
Using Javascript need of recursive html table tree