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
Hamza Shah
NA
87
23k
When increase in quantity results increase in price
Oct 20 2020 5:40 AM
In table i have product and it's quantity and price. I'm using plus and minus input button to increase or decrease the quantity of the product. I want increase and decrease in price according to the quantity. Can anyone help me Thanks in advance?
Here's my view Code
<thead>
<tr>
<th scope=
"col"
>Company</th>
<th scope=
"col"
>Product</th>
<th width=
"200px"
>Quantity</th>
<th scope=
"col"
>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td id=
"Company"
></td>
<td id=
"Product"
></td>
<td>
<div
class
=
"input-group"
>
<span
class
=
"input-group-btn"
><button
class
=
"btn btn-default value-control"
data- action=
"minus"
data-target=
"font-size"
><span
class
=
"glyphicon glyphicon-minus"
>
</span></button></span>
<input type=
"text"
value=
"1"
class
=
"form-control"
id=
"font-size"
>
<span
class
=
"input-group-btn"
><button
class
=
"btn btn-default value-control"
data-action=
"plus"
data-target=
"font-size"
><span
class
=
"glyphicon glyphicon-plus"
></span></button></span>
</div>
</td>
<td id=
"Price"
></td>
</tr>
</tbody>
<script>
$(
'#productSelect'
).change(
function
() {
var
id = $(
this
).val();
if
(id > 0) {
$.get(
"GetProduct"
, { productId: id },
function
(result) {
console.log(result)
$(
"#Company"
).text(result.CompanyName);
$(
"#Product"
).text(result.ProductName);
$(
"#Quantity"
).text(result.ProductQuantity);
$(
"#Price"
).text(result.ProductPrice);
});
}
})
</script>
And Here is my Button's javascript Code
<script>
$(document).on(
'click'
,
'.value-control'
,
function
() {
var
action = $(
this
).attr(
'data-action'
)
var
target = $(
this
).attr(
'data-target'
)
var
value = parseFloat($(
'[id="'
+ target +
'"]'
).val());
if
(action ==
"plus"
) {
value++;
}
if
(action ==
"minus"
) {
value--;
}
$(
'[id="'
+ target +
'"]'
).val(value)
})
</script>
Reply
Answers (
2
)
I am exporting excel file from gridview and allow paging to gridview
How to remove server information from the response in mvc?