# Button\_to\_function

**URL:** <https://www.ruby-forum.com/t/button-to-function/141733>\
**Category:** Rails\
**Created:** [June 30, 2008, 7:57am UTC](https://www.ruby-forum.com/t/button-to-function/141733 "2008-06-30T07:57:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [June 30, 2008, 7:57am UTC](https://www.ruby-forum.com/t/button-to-function/141733/1 "2008-06-30T07:57:43Z")

</div>

Hi  
I have  
\<%= button\_to\_function “Save As Resolved”,{‘class’ =\> ‘itilbuttonlink1’}  
do |page|  
page.visual\_effect :BlindDown, ‘here\_call\_sd\_resolution\_div’  
end %\>

Here can I use :before clause as in the case of link\_to\_remote…What I  
am trying is before the div ‘here\_call\_sd\_resolution\_div’ is shown(by  
default its visibility hidden), call a javascript to check a particular  
field is empty or not…And I want the div be shown only that field(say  
for example a text field) is non empty.How can I do this?

Thanks in advance  
Sijo

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [June 30, 2008, 10:37am UTC](https://www.ruby-forum.com/t/button-to-function/141733/2 "2008-06-30T10:37:49Z")

</div>

Hi  
I got a solution like below  
var showDivIfValuePresent = function(hiddenDiv, formField) {  
if($F(formField) {  
new Effect.BlindDown(hiddenDiv);  
}  
}

\<%= button\_to\_function “Save As Resolved”,{‘class’ =\> ‘itilbuttonlink1’}  
do |page|  
page.call :showDivIfValuePresent, :here\_call\_sd\_resolution\_div,  
:someField  
end %\>

```
 But I get an error like

```

ReferenceError showDivIfValuePresent is not defined

What may be the reason?.Please help  
Sijo
