Allen Walker wrote:

> 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

Allen, that should work for normal select changes, but the
initial state won't be set unless you add a javascript_tag
that calls either the onchange function or the display_balance
function directly.

I'd recommend that you install a Javascript debugger like
Firebug to work out what's going on.

-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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