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
Marius Vasile
590
1.9k
146.2k
asp.net core javascript not working properly
May 3 2021 5:18 PM
I am trying to hide and unhide two divs based on ddl selected text. It works in one case but for the second it does not. I get the data corect but I don't know why is not working
View
<div
class
=
"col-md-1"
>
<select id=
"AffCategory"
class
=
"form-control border-danger"
asp-items=
"@Model.SelectAffectedCategory"
asp-
for
=
"RiskAssessmentSecondary.AffectedCategory"
>
<option value=
""
>-- Select --</option>
</select>
<span asp-validation-
for
=
"RiskAssessmentSecondary.AffectedCategory"
class
=
"text-danger"
></span>
</div>
<div id=
"ATRPeople"
hidden
class
=
"col-md-1"
>
<select
class
=
"form-control border-danger"
asp-items=
"@Model.SelectJobList"
asp-
for
=
"RiskAssessmentSecondary.AtRiskPeopleDetail"
>
<option value=
""
>--Select Job Title--</option>
</select>
<span asp-validation-
for
=
"RiskAssessmentSecondary.AtRiskPeopleDetail"
class
=
"text-danger"
></span>
</div>
<div id=
"ATRAsset"
hidden
class
=
"col-md-1"
>
<select
class
=
"form-control border-danger"
asp-items=
"@Model.SelectAssetList"
asp-
for
=
"RiskAssessmentSecondary.AtRiskAssetDetail"
>
<option value=
""
>--Select Asset--</option>
</select>
<span asp-validation-
for
=
"RiskAssessmentSecondary.AtRiskAssetDetail"
class
=
"text-danger"
></span>
</div>
javascript
$(
function
() {
$(
"#AffCategory"
).on(
"change"
,
function
() {
var
data = $(
"#AffCategory :selected"
).text();
debugger
;
if
(data ==
"People"
) {
$(
"#ATRPeople"
).attr(
"hidden"
,
false
);
$(
"#ATRLabel1"
).attr(
"hidden"
,
false
);
$(
"#ATRLabel2"
).attr(
"hidden"
,
false
);
$(
"#affc"
).val(data);
}
if
(data ==
"Assets"
) {
$(
"#ATRAsset"
).attr(
"hidden"
,
false
);
$(
"#ATRLabel1"
).attr(
"hidden"
,
false
);
$(
"#ATRLabel2"
).attr(
"hidden"
,
false
);
$(
"#affc"
).val(data);
}
else
{
$(
"#ATRPeople"
).attr(
"hidden"
,
true
);
$(
"#ATRAsset"
).attr(
"hidden"
,
true
);
$(
"#ATRLabel1"
).attr(
"hidden"
,
true
);
$(
"#ATRLabel2"
).attr(
"hidden"
,
true
);
}
});
});
Reply
Answers (
1
)
How to solve the compiler error CS1061 'GridView1_RowCommand'
Cronjob in asp.net core