i want to add custom javascript to admin> product > add/edit >custom tabs like :price / general
what i want that there will be one drop down attribute on change of which i want to use ajax to autofill value in below textbox
for that i will be using ajax call on change of main dropdown
how can i do this.
i thought adding custom js code for that page only .
how can i do this i want magento like ajax loader when drop down change ?…
any help please could not find any proper guide or link for such case
Best Answer
Since you have already created the attribute, you can add some layout XML to inject a helper script:
For the product edit area only. You can place this in your related module's layout XML or else in
app/design/adminhtml/default/default/layout/local.xml
. So in the JS, I presume you'll be observing thechange
event of the targetselect
element. On trigger, you'll make an AJAX call to ... ? I don't know that either, but if it's going to route back through Magento to get that information, you will likely need to also setup a controller.Alternate Method
Another way to get the JS in place is to specify an "input renderer" when installing your attribute. Here's an article on how to do that: http://inchoo.net/magento/adding-magento-attribute-with-custom-input-renderer/
To summarize the article, install your attribute like so:
Notice the
input_renderer
field. This maps to a block which renders the form field for your attribute, like so:You might not want to do this because your attribute is already installed, but I tend to prefer this method because of how tightly it couples the JS with the attribute.