Reputation: 21
I have 4 Checkboxes and a Label. Each checkbox represents an item. The label on the other hand will display the price of the item that has been checked.
Now, I want to know the code for displaying the calculation in the label. For example if checkbox 1 and checkbox 2 are banana and apple respectively, and the prices are $2 and $3 repectively, and they are both checked then the label will display 2+3 = $5.
Upvotes: 0
Views: 186
Reputation: 511
Let's say that you have a variable amount
.
When a Checkbox
( assign a name for the checkbox. Here I'll assume it's item
) is clicked, you have to update the variable amount
and set the value of this to the Label
.
You can use OnClick()
method and check the Checked
status to perform this. Since you have not written any code, I'd suggest you try it on your own.
Upvotes: 2