Jquery: What is the ID for form field? | Experience Community
Skip to main content
Solved

Jquery: What is the ID for form field?

  • Sep 8, 2018 7:38 PM UTC
  • 6 replies
  • 269 views

deleted

Best answer by Anonymous

Hello @mrl , Follow this post The text entry id is ``QR~QID24~1`` i.e QR~this.questionId~1, where 1 is the position of the input text. Also in JQuery we use this as `jQuery("[id='QR~QID24~1']").autocomplete({});`
View original

6 replies

PeeyushBansal
Level 7 ●●●●●●●
Forum|alt.badge.img+53
  • Level 7 ●●●●●●●
  • Sep 9, 2018 2:46 AM UTC
You have to append box Id in [] Something like jQuery('#' + qid + ' .InputText')[0].setAttribute('placeholder',placeholder1);

PeeyushBansal
Level 7 ●●●●●●●
Forum|alt.badge.img+53
  • Level 7 ●●●●●●●
  • Sep 9, 2018 2:48 AM UTC
You can also refer below code https://gist.github.com/mattbloomfield/ff4609bd60d697d1b1c7f617d046c8e1

  • Author
  • Sep 9, 2018 3:02 AM UTC
Thanks for the speedy response! I tried the code in these ways but the code becomes invalid when I do this and I made sure to define qid as this.questionId at the start of the code. Is there something else I should be doing?

  • Answer
  • Sep 9, 2018 5:32 AM UTC
Hello @mrl , Follow this post The text entry id is ``QR~QID24~1`` i.e QR~this.questionId~1, where 1 is the position of the input text. Also in JQuery we use this as `jQuery("[id='QR~QID24~1']").autocomplete({});`

  • Author
  • Sep 9, 2018 11:30 PM UTC
deleted

  • Sep 10, 2018 5:12 AM UTC
> @mrl said: > That's exactly it! it works perfectly now. Is there anyway to conveniently index the ID's of all the form field like this ``id='QR~QID24~[1:4]]").autocomplete``? I Yes this is possible. Paste the following code in the js(OnReady) option of the question: jQuery("#"+this.questionId+" .InputText").each(function(index){ jQuery(this).autocomplete({}); }); Now in the above code we can use "index" variable to know which text entry is currently in the loop and the index starts from "0" to "2", if we have three input text.