# Clicking image to change variable

**URL:** <https://www.ruby-forum.com/t/clicking-image-to-change-variable/129602>\
**Category:** Rails\
**Created:** [February 20, 2008, 12:26am UTC](https://www.ruby-forum.com/t/clicking-image-to-change-variable/129602 "2008-02-20T00:26:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nition](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f05b48/32.png) [@nition](https://www.ruby-forum.com/u/nition)\
**Post date:** [February 20, 2008, 12:26am UTC](https://www.ruby-forum.com/t/clicking-image-to-change-variable/129602/1 "2008-02-20T00:26:51Z")

</div>

I’m still pretty new to rails but I’ve got a lot of the basic stuff  
working.

On one page I have a set of images, and I’d like to make it so that  
clicking them will change a variable I have. Is there a simple method  
for mouse click on object triggers -\> do something? I’m still learning  
all the available commands.

Thanks

---

<div class="post-metadata">

**Author:** ![nition](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f05b48/32.png) [@nition](https://www.ruby-forum.com/u/nition)\
**Post date:** [February 20, 2008, 12:47am UTC](https://www.ruby-forum.com/t/clicking-image-to-change-variable/129602/2 "2008-02-20T00:47:44Z")

</div>

> I’m still pretty new to rails but I’ve got a lot of the basic stuff  
> working.
> 
> On one page I have a set of images, and I’d like to make it so that  
> clicking them will change a variable I have. Is there a simple method  
> for mouse click on object triggers -\> do something? I’m still learning  
> all the available commands.

Look into link\_to\_function (if it’s all client side) or link\_to\_remote.

-philip

---

<div class="post-metadata">

**Author:** ![nition](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f05b48/32.png) [@nition](https://www.ruby-forum.com/u/nition)\
**Post date:** [February 20, 2008, 2:30am UTC](https://www.ruby-forum.com/t/clicking-image-to-change-variable/129602/3 "2008-02-20T02:30:22Z")

</div>

Philip H. wrote:

> Look into link\_to\_function (if it’s all client side) or link\_to\_remote.
> 
> -philip

That should work. Thanks
