# How to update more than one div through form\_remote\_tag

**URL:** <https://www.ruby-forum.com/t/how-to-update-more-than-one-div-through-form-remote-tag/158286>\
**Category:** Rails\
**Created:** [January 21, 2009, 5:26pm UTC](https://www.ruby-forum.com/t/how-to-update-more-than-one-div-through-form-remote-tag/158286 "2009-01-21T17:26:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sauravsuman012](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@sauravsuman012](https://www.ruby-forum.com/u/sauravsuman012)\
**Post date:** [January 21, 2009, 5:26pm UTC](https://www.ruby-forum.com/t/how-to-update-more-than-one-div-through-form-remote-tag/158286/1 "2009-01-21T17:26:20Z")

</div>

# Hi All I have to update more than a single DIV through form\_remote\_tag . I am posting my code . In rhtml page

\<%= form\_remote\_tag({:url=\>{:controller=\>‘image\_builders’, :action  
=\>‘image\_creation’}, :update =\>‘photo’,  
:html=\>{:onsubmit=\>‘UrlGeneration(this)’}})%\>

  
Type  
  
Slash  
Strip  
Dot  
Gradation  
  
Margin  
 px

```
      <dt>Line Color</dt>
      <dd>
      <div style="margin-bottom:5px"><input name="linetrans"

```

id=“linetrans” type=“checkbox” onClick=“showHideBox(this,‘line’)” /\>  
Transparent

  

  
Line Color:   
\<%= text\_field\_tag ‘linecolor’, ‘#000000’,  
:onfocus=\>“blur()”%\>  
&nbsp;  

  

```
      <dt>Background Color</dt>
      <dd>
      <div style="margin-bottom:5px"><input name="bgtrans"

```

id=“bgtrans” checked=“checked” type=“checkbox”  
onClick=“showHideBox(this,‘background’)” /\> Transparent

  

  
Background Color:   
\<%= text\_field\_tag ‘bgcolor’, ‘#FFFFFF’, :onfocus=\>“blur()” %\>  
&nbsp;  

  

```
      <dt>Size</dt><dd>

      <input name="auto" id="auto" checked="checked" type="checkbox"

```

onclick=“enable\_field(auto, width, height)”\> Auto   
  
  
width   
height

Alpha  
  
  
between 0(opaque)  
and 127(transparent)

```
      </dd>
      <dt>Options</dt><dd><input name="reverse" id="reverse"

```

value=“1” type=“checkbox”\> Reverse

  
  
\<%= submit\_tag ‘Create Image’ %\>  

```
  <!-- end customize -->

    </td>
    <td width="65%" valign="top" align="left">

  <!-- start preview --><h2>Preview</h2>

    <div id='result'>

      <div><label for='url'><b>URL:</b></label>
      <%= text_field_tag 'url', @url_for , :size => 75

```

,:onFocus=\>‘this.select()’%\>

```
      </div>
      <div>
      <label><b>Image:</b></label>
      <div id="photo" style="width:99%;">
        <img src='/images/xyz.png'/>
      </div>
      </div>

      <div>
      <label><b>Sample Area:</b></label>

      <div class="prv" id="photo" >

        <div id="sample1" style="width:200px; height:200px;

```

margin-left:5px; background:url(’’) repeat top left;"\>

**Sample**
  

  

  

  

  
  

```
    </div>
  <!-- end preview -->

```

=============================================================================

# As i am updating “photo” here , I have to refresh the other div’s like Sample1, Sample2,Sample3,Sample4 also

Code in my controller

```
# Creation of Gradition Image
if params[:id] == 'gradation'
  if params[:linetrans]
    @line_color = "#000000"
  end
  if params[:bgtrans]
    @bg_color = "#FFFFFF"
  end
  fill = Magick::GradientFill.new(0, 0, 0, @Width, @line_color,

```

# @bg\_color) img = Magick::Image.new(@Height, @Width, fill) img.opacity = @alpha/ 127.0 \* Magick::TransparentOpacity if @alpha != 0 img\_new = img.rotate(90) if params[:reverse] img\_rev = img\_new.rotate(270) img\_rev.write(“public/images/bgmaker/gradation/xyz.png”) render :text =\> “” else img\_new.write(“public/images/bgmaker/gradation/xyz.png”) render :text =\> “” end end

If anybody having any solution please let me know , it would be great  
help for me .

Thanks In Advance

---

<div class="post-metadata">

**Author:** ![sauravsuman012](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@sauravsuman012](https://www.ruby-forum.com/u/sauravsuman012)\
**Post date:** [January 21, 2009, 6:57pm UTC](https://www.ruby-forum.com/t/how-to-update-more-than-one-div-through-form-remote-tag/158286/2 "2009-01-21T18:57:06Z")

</div>

On Jan 21, 2009, at 8:26 AM, Kumar S. wrote:

> # =
> 
> # =
> 
> \<%= form\_remote\_tag({:url=\>{:controller=\>‘image\_builders’, :action  
> =\>‘image\_creation’}, :update =\>‘photo’,  
> :html=\>{:onsubmit=\>‘UrlGeneration(this)’}})%\>

First, you don’t want to pass an :update option to form\_remote\_tag.  
Then you want to start reading about update\_page here:

[http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001436](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001436)

Basically you’ll return some javascript which will do whatever you  
want… updating divs, hiding stuff, replacing other stuff, etc…

-philip
