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
Leah Kunkie
NA
44
3.6k
enable form control on selecting item from drop
Jan 17 2020 3:45 AM
I am trying to enable form elements when selecting the first drop down with id LId3, I took the code from a button. The problem starts when I enable the searchable dropdown, when i open the searchable dropdown the form elements are not enabled. When the dropdown is clickable the form elements get enabled. Please assist with the below:
<script src=
"https://code.jquery.com/jquery-1.12.4.min.js"
></script>
<form asp-controller=
"Leaves"
asp-action=
"Create"
method=
"post"
class
=
"form-horizontal"
role=
"form"
>
<div asp-validation-summary=
"ModelOnly"
></div>
<script src=
"https://code.jquery.com/jquery-1.12.4.min.js"
></script>
<div
class
=
"form-group"
style=
"display: flex"
>
<script type=
"text/javascript"
>$(document).ready(
function
() {
$(
"#GFG :input"
).prop(
"disabled"
,
true
);
});
function
enable_disable() {
$(
"#GFG :input"
).prop(
"disabled"
,
false
);
}</script>
<input
class
=
"form-control col-sm-2"
data-toggle=
"tooltip"
data-placement=
"left"
title=
"Employee Identiy Number"
readonly />
<div
class
=
"col-sm-3"
>
<select onclick=
"enable_disable()"
class
=
"form-control"
value=
"Enable"
id=
"LId3"
>
</select>
</div>
</div>
</form>
<form asp-controller=
"Leaves"
asp-action=
"Create"
method=
"post"
class
=
"form-horizontal"
role=
"form"
id=
"GFG"
>
<div asp-validation-summary=
"ModelOnly"
></div>
<div
class
=
"form-group"
style=
"display: flex"
>
<input
class
=
"form-control col-sm-2"
value=
"Name"
data-toggle=
"tooltip"
data-placement=
"left"
title=
"Name of employee"
readonly />
<div
class
=
"col-sm-3"
>
<select asp-
for
=
"LId"
id=
"LId1"
class
=
"form-control"
asp-items=
"@(new SelectList(ViewBag.ListOfTable,"
LId
", "
EmpName
"))"
>
</select>
</div>
</div>
<div
class
=
"form-group"
style=
"display: flex"
>
<input
class
=
"form-control col-sm-2"
disabled value=
"Surname"
data-toggle=
"tooltip"
data-placement=
"left"
title=
"Surname of employee"
readonly />
<div
class
=
"col-sm-3"
>
<select asp-
for
=
"LId"
id=
"LId2"
class
=
"form-control"
asp-items=
"@(new SelectList(@ViewBag.ListOfTable,"
LId
", "
EmpSurname
"))"
>
</select>
</div>
</div>
<div
class
=
"form-group"
style=
"display: flex"
>
<input
class
=
"form-control col-sm-2"
value=
"Type of Leave"
readonly />
<div
class
=
"col-sm-3"
>
<select asp-
for
=
"TypeOfLeave"
name=
"offer"
id=
"leave"
class
=
"form-control"
>
<option value=
"0"
>Select</option>
<option value=
"Sick"
>Sick</option>
<option value=
"Family Responsibility"
>Family Responsibility</option>
<option value=
"Study"
>Study</option>
<option value=
"Vacation"
>Vacation</option>
<option value=
"Bereavement"
>Bereavement</option>
<option value=
"TimeOffWithoutPay"
>Time Off Without Pay</option>
<option value=
"Military"
>Military</option>
<option value=
"JuryDuty"
>Jury Duty</option>
<option value=
"Maternity/Paternity"
>Maternity/Paternity</option>
<option value=
"Other"
>Other</option>
</select>
<span asp-validation-
for
=
"TypeOfLeave"
class
=
"text-danger"
></span>
</div>
</div>
</form>
Reply
Answers (
2
)
Reading mac address in C# 8
Inserting Data To SQL Global Temporary Table From ASP.NET C#