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

Jquery: What is the ID for form field?

  • September 8, 2018
  • 6 replies
  • 193 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({});`

6 replies

PeeyushBansal
Level 6 ●●●●●●
Forum|alt.badge.img+44
  • Level 6 ●●●●●●
  • September 9, 2018
You have to append box Id in [] Something like jQuery('#' + qid + ' .InputText')[0].setAttribute('placeholder',placeholder1);

PeeyushBansal
Level 6 ●●●●●●
Forum|alt.badge.img+44
  • Level 6 ●●●●●●
  • September 9, 2018
You can also refer below code https://gist.github.com/mattbloomfield/ff4609bd60d697d1b1c7f617d046c8e1

  • Author
  • September 9, 2018
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
  • September 9, 2018
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
  • September 9, 2018
deleted

  • September 10, 2018
> @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.