Hello i have 5 fields from an invoice system (code,name,price,qty,total)
i want when the user insert a code, the system automatically fill all
the info from the DB into these columns.
any ideas pleased?
Hello i have 5 fields from an invoice system (code,name,price,qty,total)
i want when the user insert a code, the system automatically fill all
the info from the DB into these columns.
any ideas pleased?
Edgar O. wrote:
Hello i have 5 fields from an invoice system (code,name,price,qty,total)
i want when the user insert a code, the system automatically fill all
the info from the DB into these columns.any ideas pleased?
A field observer on the code field.
Then, in the controller, you retrieve the object from db and then update
the page using rjs, like:
render :update do |page|
page[‘name’].value=your_object.name
page[‘price’].value=your_object.price
…
end
Regards
Massimo
http://www.addsw.it
Now i am confused with the observer, should look like this?
:item_codigo = field with the data i received
:update => ‘articulos’ = is the div where is my field
get_X_code = mehod on my controller
<%= observe_field(:item_codigo,
:frequency => 0.5,
:update => ‘articulos’,
:url => { :action => :get_X_code},
:with => “‘codigo_id=’+escape(value)”)%>
??
maner wrote:
Edgar O. wrote:
Hello i have 5 fields from an invoice system (code,name,price,qty,total)
i want when the user insert a code, the system automatically fill all
the info from the DB into these columns.any ideas pleased?
A field observer on the code field.
Then, in the controller, you retrieve the object from db and then update
the page using rjs, like:render :update do |page|
page[‘name’].value=your_object.name
page[‘price’].value=your_object.price
…
endRegards
Massimo
http://www.addsw.it
how can i do the observer???
And when i pass the object to the .rjs template it return [object
object]
Edgar O. wrote:
how can i do the observer???
And when i pass the object to the .rjs template it return [object
object]
In your view:
<%= observe_field(‘item_codigo’,
:url => { :action => :get_X_code},
:with => “codigo_id”) %>
No :update option is needed, since response is RJS
In controller:
item=Item.find_by_codigo_id(params[:codigo_id])
render :update do |page|
page[‘item_name’].value=item.name
…
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs