Mark Reginald James wrote:
> Allen Walker wrote:
>> No such luck again. Here's the generated HTML:
> 
> Looking at the Prototype code, observe only calls
> the function if the value has actually changed.
> 
> So one way would be to move the observer inline:
> 
> :onchange => remote_function(:url => ...)
> 
> Or in this case it would be faster & simpler to keep
> everything client-side:
> 
> function display_balance(gstatus) {
>    if (gstatus == '' || gstatus == 'Due')
>      $("balance_div").hide();
>     else
>       $("balance_div").show();
> }
> 
> :onchange => 'display_balance(value)'
> 
> <%= javascript_tag "$('guarantee_status').onchange()" %>
> 
> --
> Rails Wheels - Find Plugins, List & Sell Plugins - 
> http://railswheels.com

Trying the client side I did:

<%= f.select :status, [['Due','Due'],['In Progress','Paid']], {}, 
{:onchange => 'display_balance(value)'} %>

and played in application.js:

function display_balance(gstatus) {
    if (gstatus == '' || gstatus == 'Due')
        $("balance_div").hide();
    else
        $("balance_div").show();
}

Generated HTML:

<select id="guarantee_status" name="guarantee[status]" 
onchange="display_balance(value)"><option value="Due">Due</option>
<option value="Paid" selected="selected">In Progress</option></select>
  </p>

<div id="balance_div" style="display:none">
  <p>
    <b>Remaining Balance</b> )<br />
    <input id="guarantee_balance" name="guarantee[balance]" size="30" 
type="text" value="2430.0000" />
  </p>
</div>


It doesn't work. I'm sure I'm missing something. I'm pretty unskilled of 
javascript
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to