1

I have three product attributes named gross_weight,stone_weight & net_weight. While entering stone_weight the net_weight should be calculated using jquery. But jquery is not recognizing input field by its name. input field names are like name="product[net_weight]".

Please suggest any solution for this problem.

Khoa Truong
32.5k11 gold badges91 silver badges159 bronze badges
asked Dec 27, 2016 at 11:10

1 Answer 1

1

We can simply call with backslashes:

$('input[name="product\\[net_weight\\]"]')

enter image description here

To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \. For example, an element with id="foo.bar", can use the selector $("#foo\.bar")

We can see more here:

answered Dec 27, 2016 at 16:50
6
  • a big thanks for helping me. but i cannot able to trigger change or keyup events using the same logic Commented Dec 29, 2016 at 5:00
  • @ShiyasPathiyassery you should open new question. I will take a look. Commented Dec 29, 2016 at 5:01
  • Bro actually my question is really regarding the same issue. ie, event based on this element(s) not working properly so i cannot able to do anything with change or keyup events. Commented Dec 29, 2016 at 6:31
  • I think it is a different issue. I know your issue may related to UI component. You cannot bind the event to the elements? Commented Dec 29, 2016 at 6:34
  • Yes bro. That's what my actual problem. how to solve this problem Commented Dec 29, 2016 at 6:40

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.