Jquery: What is the ID for form field? | XM Community
Skip to main content
deleted
You have to append box Id in []



Something like



jQuery('#' + qid + ' .InputText')[0].setAttribute('placeholder',placeholder1);
You can also refer below code



https://gist.github.com/mattbloomfield/ff4609bd60d697d1b1c7f617d046c8e1
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?
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({});`
deleted
> @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.

Leave a Reply