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
Denmark Puso
NA
232
50.6k
how can i change the value of textbox using function?
May 22 2020 2:10 AM
i need to subtract the amount when i click the checkbox. but my textbox amount didnot change the value inputed. when ill try to alert the total the value is show correct. how can i change the value of textbox amount when i click checkbox. thanks
@Html.LabelFor(
x
=
>
x.Amount, new { @
class
=
"form-label"
})
@Html.TextBoxFor(
x
=
>
x.Amount, new { @
class
=
"form-control"
, @
id
=
"Amount"
})
$(
function
() {
$(
'#Payable'
).DataTable({
"ajax"
:
"@Url.Action("
getpayablelist
", "
payment
")"
,
"columns"
: [
{
"render"
:
function
(data, type, full, meta) {
return
"<input type='checkbox' class='checkbox' onclick='add("
+ full.Id +
", "
+ full.Amount +
", this.checked)'>"
}
},
{
"data"
:
"Type"
},
{
"data"
:
"ReferenceNo"
},
{
"data"
:
"Amount"
}
]
});
});
ar ids = [];
function
add(id, amount, isChecked) {
var
total = $(
'#Amount'
).val();
if
(isChecked) {
ids.push(id);
total = total - amount;
alert(total);
}
else
{
var
i = ids.indexOf(id);
ids.splice(i, 1);
}
}
Reply
Answers (
1
)
How to displaying user filled form data using javascript?
download a text file