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
148.6k
asp.net core jquery not functioning when ddl is empty
May 16 2021 1:24 PM
I have a select and a textbox handled by a jquery. Basically, if I select a value from ddl, the textbox became disabled and if I enter text in the textbox, the ddl became disabled. The problem I have is: If the ddl is empty, the jquery does not work. How can I fix this?
<div
class
=
"row no-gutters"
onchange=
"funcLocation()"
>
<div
class
=
"col-md-2"
>
<label
class
=
"form-control text-white"
style=
"background-color:mediumorchid;"
>Location </label>
</div>
@
if
(Model.RALocation ==
true
)
{
<div
class
=
"col-md-3"
>
<select id=
"LocS"
class
=
"form-control border-danger"
asp-items=
"@Model.SelectLocation"
>
<option value=
""
>--Select Location--</option>
</select>
</div>
<span
class
=
"text-danger ml-2 mr-2"
>OR</span>
}
<div
class
=
"col-md-3"
>
<input id=
"LocT"
class
=
"form-control"
placeholder=
"Enter New Location"
/>
<input id=
"loc"
asp-
for
=
"RiskAssessmentMain.Location"
/>
</div>
</div>
function
funcLocation() {
var
data1 = $(
"#LocS :selected"
).text();
var
data2 = $(
"#LocT"
).val();
if
(data2.length > 0) {
$(
"#LocS"
).attr(
"disabled"
,
true
);
$(
"#loc"
).val(data2);
}
else
{
$(
"#LocS"
).attr(
"disabled"
,
false
);
}
if
(data1 !=
"--Select Location--"
) {
$(
"#LocT"
).empty();
$(
"#LocT"
).attr(
"disabled"
,
true
);
$(
"#loc"
).val(data1);
}
else
{
$(
"#LocT"
).attr(
"disabled"
,
false
);
}
}
Reply
Answers (
3
)
Itextsharp is showing a pdf with blank pages
asp.net core textbox autocomplete with jquery and json