I have created two attributes from magento catalog attributes. I want to hide and show attribute on basis of second attribute value. I added a js file to the main.xml file like this :

<action method="addJs"><script>mage/adminhtml/custom.js</script></action>

Now i want to alert a value of attribute for that i added alert($('#is_product_returnable').val()); to the custom.js file.

But its not working. How can i achieve this using my custom.js file or is there any other way i can hide/show attribute?

  • can you post a website link ? – Anil Suthar Jun 1 '16 at 8:10
  • No i can't but this is the error i am getting TypeError: $(...) is null – Seefan Jun 1 '16 at 8:53
  • please show an HTML for this element : is_product_returnable. Also are you using jQuery OR prototype ? – Anil Suthar Jun 1 '16 at 9:11
  • This is the html for the attribute : <select class=" select" name="product[is_product_returnable]" id="is_product_returnable"> <option selected="selected" value="0">No</option> <option value="1">Yes</option> </select> – Seefan Jun 1 '16 at 9:15
  • just trying to alert value for this attribute – Seefan Jun 1 '16 at 9:16

For prototype, use this:

document.observe("dom:loaded", function() {

For jQuery, use this:

  • thanks but it didn't work . – Seefan Jun 1 '16 at 9:54
  • check updated answer – Anil Suthar Jun 1 '16 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.