# Web app - button to change value

**URL:** <https://www.ruby-forum.com/t/web-app-button-to-change-value/240591>\
**Category:** Ruby\
**Created:** [April 22, 2014, 9:31am UTC](https://www.ruby-forum.com/t/web-app-button-to-change-value/240591 "2014-04-22T09:31:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [April 22, 2014, 9:31am UTC](https://www.ruby-forum.com/t/web-app-button-to-change-value/240591/1 "2014-04-22T09:31:19Z")

</div>

Hi guys,

I’ve made a small web app with camping and I’d need some advise how to  
approach the task in the subject: to implement a button that would  
change (increase or decrease a value; like a +/- counter).

I’m not looking for a solution as I need to learn this, so I’d really  
appreciate if someone can point me in the right direction. I need this  
button to be a part of the html (I’m using markaby) form I’ve setup in  
my view. Do I need to include jQuery or javascript?

regards  
seba

---

<div class="post-metadata">

**Author:** ![sebastjan\_h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@sebastjan\_h](https://www.ruby-forum.com/u/sebastjan_h)\
**Post date:** [April 22, 2014, 12:24pm UTC](https://www.ruby-forum.com/t/web-app-button-to-change-value/240591/2 "2014-04-22T12:24:38Z")

</div>

Sebastjan H. wrote in post #1143725:

> Hi guys,
> 
> I’ve made a small web app with camping and I’d need some advise how to  
> approach the task in the subject: to implement a button that would  
> change (increase or decrease a value; like a +/- counter).
> 
> I’m not looking for a solution as I need to learn this, so I’d really  
> appreciate if someone can point me in the right direction. I need this  
> button to be a part of the html (I’m using markaby) form I’ve setup in  
> my view. Do I need to include jQuery or javascript?
> 
> regards  
> seba

For reference: I’ve used the html 5 input type “number”, supported by  
markaby and it works. On hover the spinner is shown and enables  
increasing or decreasing the element value. Unfortunatelly it only works  
in opera. It also works in chrome, but not in FF.

regards  
seba

---

<div class="post-metadata">

**Author:** ![sebastjan\_h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@sebastjan\_h](https://www.ruby-forum.com/u/sebastjan_h)\
**Post date:** [April 22, 2014, 9:13pm UTC](https://www.ruby-forum.com/t/web-app-button-to-change-value/240591/3 "2014-04-22T21:13:24Z")

</div>

You may get more responses by asking on the Rails forum 🙂

---

<div class="post-metadata">

**Author:** ![sebastjan\_h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@sebastjan\_h](https://www.ruby-forum.com/u/sebastjan_h)\
**Post date:** [April 23, 2014, 11:42am UTC](https://www.ruby-forum.com/t/web-app-button-to-change-value/240591/4 "2014-04-23T11:42:35Z")

</div>

Joel P. wrote in post #1143786:

> You may get more responses by asking on the Rails forum 🙂

Thank you for the reminder, I’ll setup camp there for the next  
question;)  
regards  
seba

---

<div class="post-metadata">

**Author:** ![sebastjan\_h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@sebastjan\_h](https://www.ruby-forum.com/u/sebastjan_h)\
**Post date:** [April 26, 2014, 5:02am UTC](https://www.ruby-forum.com/t/web-app-button-to-change-value/240591/5 "2014-04-26T05:02:44Z")

</div>

Sebastjan H. wrote in post #1143751:

> > Do I need to include jQuery or javascript?

javascript, at least. You want to perform some action when a button is  
clicked, so you have to setup an onclick handler for your button. The  
onclick hander will execute a javascript function that you define. Your  
function can search for any html element, e.g. the element displaying  
your number and change it. If you want, you can use the onclick event  
to display a spinner–in that case jquery ui is the way to go:

> **[Spinner | jQuery UI](https://jqueryui.com/spinner/)**
>
> jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly interactive web applications or you just need to add a date picker to a form...

Try that toggle button. Your button click can be used to toggle the  
spinner so that it becomes visible. But then you do have to spend  
some time learning jquery.

> For reference: I’ve used the html 5 input type “number”, supported by  
> markaby and it works. On hover the spinner is shown and enables  
> increasing or decreasing the element value. Unfortunatelly it only works  
> in opera. It also works in chrome, but not in FF.

Then it doesn’t look like you are going to be using an html5 input  
element, type=number. The nice thing about jquery is that it is  
crossbrowser.
