justinmind-logo
 
Upvote 1

Cant set limits on increasing and decreasing numbers

Known Helpme 5 years ago

Hi,

I've just found this brilliant program. I'm not knowledgeable about js. CSS & html i can handle. I'm trying to create a box with + & - either side to increase or decrease the numbers fixed with a value on them for instand 1 up till 4 will be £0 then 5 - 50 will be £4.95.


Now the trouble i'm facing i've read your documentation (very nice by the way) I have managed to create the +- functions on the input field but i don't know how to add a value then calculate each individual sum plus stop it from going below 0 and above 50.

Then it displays the cost in the bottom box.

If someone could help that would be great. i've attached my basic markup to this post for you to see what i mean.


It's alot to ask but i really want to figure this out. Thank you in advance.

Replies (1)
photo
1

Hi there,

Check out the attached edited prototype, which does what you're looking for.

To do this, we created conditions for the set value events, which are When... [input] > 0 for the - sign, and When... [input] < 50 for the + sign. We also created a variable to store the box input value, which we used to set the value of a text that holds the current price. The event to set the price is an "on variable change" event, which detects when the variable has been changed (when it is greater 5, because you note that the first 5 boxes are free) and then multiples that variable's value by the price per box. Lastly, we rounded the price to the nearest 0.01.

Let me know if you have any questions.

Best,

Danielle

Leave a Comment
 
Attach a file