⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

autofill



dhoni223

dhoni223
  • profile picture
  • Member

Posted 15 February 2018 - 07:33 AM

i want to autofill some column based on id in add forum


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 16 February 2018 - 03:53 AM

i am confused on the same - add form dose not have any id.. so how you plan to set values .,.and on what basis?


dhoni223

dhoni223
  • profile picture
  • Member

Posted 22 February 2018 - 06:14 AM

i have one table with id and other table with price if i type id or select it from dropdown it should autofill the price field


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 23 February 2018 - 05:10 AM

Steps to achieve the same:

 

1. Have to write a script in a JS file which will handle the on change event for the drop down (the source element)

2. In script - make Ajax call to retrieve the price based on the value of selected element.

3. Write a action in controller to retrieve and send back the price / output to the request

4. In the success function for the ajax call - set the value of the field with the element retrieved from the ajax request.

 

1 more important info - add the js in action using set_js function ...

and in the js - call for window.onload function and not $.ready - the $.ready will fail...

 

That's the way u do it..

 

Happy GCing :)


dhoni223

dhoni223
  • profile picture
  • Member

Posted 23 February 2018 - 10:27 AM

thanks i ll try dis 

can u send any examples