autopopulate same table

A place for users and developers of the Xataface to discuss and receive support.

autopopulate same table

Postby tomtom8 » Thu Aug 09, 2012 3:44 am

Hello!
I have to fill out a form, if a field is already present in the database can automatically fill in other fields. Basically I have a table with field WorkOrder (cod_odl) and fields such as, (name) (address), (tel) etc. .. If completing a new Form I insert the field (cod_cli) and this is already in the db, I can automatically populate the remaining fields as: (name) (address), (tel), etc..
Thank you.

Michele
tomtom8
 
Posts: 17
Joined: Mon Jul 30, 2012 6:56 am

Re: autopopulate same table

Postby shannah » Thu Aug 09, 2012 11:23 am

If you wanted to populate this in the form (i.e. before submitting it) then you'll need to use some javascript and ajax. If I were you, I'd create an action that returns JSON with the data you need. Then create a Javascript function that responds to the onchange handler for your field that calls your ajax action and uses the data to populate the other fields.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: autopopulate same table

Postby mermentau » Tue Nov 20, 2012 9:35 am

shannah wrote:If you wanted to populate this in the form (i.e. before submitting it) then you'll need to use some javascript and ajax. If I were you, I'd create an action that returns JSON with the data you need. Then create a Javascript function that responds to the onchange handler for your field that calls your ajax action and uses the data to populate the other fields.
I really need this functionality. Any clues where I could find more detailed documentation?
mermentau
 
Posts: 14
Joined: Tue Nov 20, 2012 9:26 am

Re: autopopulate same table

Postby shannah » Tue Nov 20, 2012 10:53 am

I don't have an example of this exactly. But the steps would roughly be:

1. Create a custom action that takes, as input, the field that is selected, and outputs the the data that you intend to use to prepopulate the other fields.
2. Create a Javascript function that uses AJAX to call your custom action, and populate the fields.
3. Attach a change handler to the field that should trigger this, and call your javascript function.
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: autopopulate same table

Postby mermentau » Wed Nov 28, 2012 7:21 pm

Sorry shannah I missed your response here. I didn't realize we had to manually subscribe to the thread. Anyway I was able to solve the problem with JavaScript. Not exactly as you described, but it's working.
mermentau
 
Posts: 14
Joined: Tue Nov 20, 2012 9:26 am


Return to Xataface Users

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved