Web app - button to change value

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

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

You may get more responses by asking on the Rails forum :slight_smile:

Joel P. wrote in post #1143786:

You may get more responses by asking on the Rails forum :slight_smile:

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

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:

http://jqueryui.com/spinner/

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs