Autocomplete + Infopath 2010

Feb 29, 2012 at 3:37 PM
Edited Feb 29, 2012 at 3:38 PM

Thanks! It's great solution for sharepoint list form, it perfectly work on EditForm.aspx and NewForm.aspx

But when I develop and publish infopath form - autocomplete script remove from new editfs.aspx.

I try to put code manually into editfs.aspx and newfs.aspx   after   <WpNs0:BrowserFormWebPart  and start from <WebPartPages:ContentEditorWebPart

- doesn't work. Can you say me - what's the problem and how can i fix it?

Coordinator
Mar 1, 2012 at 9:03 AM

Hi,

InfoPath forms are currently not supported, but you can manually change the JQuery selector.

Here is an example html code from an InfoPath Text Field called 'timestamp'

<tr class="h_U7ch0fnX0ngUhFdP_0 ah_U7ch0fnX0ngUhFdP_0">
<td class="e_U7ch0fnX0ngUhFdP_0 i_U7ch0fnX0ngUhFdP_0 ab_U7ch0fnX0ngUhFdP_0">
<h4 class="l_U7ch0fnX0ngUhFdP_0 ah_U7ch0fnX0ngUhFdP_0">
<span class="ah_U7ch0fnX0ngUhFdP_0">timestamp</span>
</h4>
</td>
<td class="e_U7ch0fnX0ngUhFdP_0 j_U7ch0fnX0ngUhFdP_0 ac_U7ch0fnX0ngUhFdP_0">
<span style="white-space: nowrap;" onmouseover="return LeafControl.OnWrappingSpanMouseOver(this, event);" onmouseout="return LeafControl.OnWrappingSpanMouseOut(this, event);" class="o_U7ch0fnX0ngUhFdP_0 an_U7ch0fnX0ngUhFdP_0 ao_U7ch0fnX0ngUhFdP_0">
<input onfocus="return (TextBox.OnFocus(this, event));" onblur="return (TextBox.OnBlur(this, event));" oninput="return (TextBox.OnInput(this, event));" id="ctl00_m_g_f28da90c_a5db_4f88_b041_7db0a787de70_FormControl0_V1_I1_T3" scriptclass="TextBox" class="p_U7ch0fnX0ngUhFdP_0 ad_U7ch0fnX0ngUhFdP_0 ap_U7ch0fnX0ngUhFdP_0" wrapped="true" direction="ltr" viewdatanode="4" formid="ctl00_m_g_f28da90c_a5db_4f88_b041_7db0a787de70_FormControl0" originalid="V1_I1_T3" tabindex="0" title="" value="1222" style="position: relative;" type="text">
</span>
</td>
</tr>

A simple static solution: get the input element by ID e.g.:  $('#ctl00_m_g_f28da90c_a5db_4f88_b041_7db0a787de70_FormControl0_V1_I1_T3')

Mar 1, 2012 at 10:08 AM

Hi,

Thanks for your reply!

Sorry, but I don't understand where I must past this example code - is it into view1.xsl ?

For example, I have source list "ttt", source field ""ttt_field" and target list "target2", target field "target2_field". I create Form_Suggestion_List Item, create and publish InfoPath form, after that paste JS into editifs.aspx. Then I must paste html code into view1.xsl ? And put get the input element $('#   into JS?

Sorry, I'm not pro on aspx & js...(

Coordinator
Mar 1, 2012 at 10:25 AM

Hi,

create your InfoPath Form, open it with your browser, search for the field html code like above and find the ID of the <input ... Element

create a CotentEditor WebPart, paste the JS Code and replace 

$("input[title='target2_field']").autocomplete

with

$("#ID_OF_THE_INPUT_ELEMENT").autocomplete

(e.g.
$("#ctl00_m_g_f28da90c_a5db_4f88_b041_7db0a787de70_FormControl0_V1_I1_T3").autocomplete)



Mar 1, 2012 at 11:30 AM

Thanks a lot!!! It works!! ) Perfect

Mar 14, 2012 at 12:55 PM

Hi,

one more question - how can i use it on combobox filed? there are 2 fields in combobox - id looks like that: 

 

ctl00_ctl22_g_0faf3784_1c04_4644_8345_21a511739cfc_FormControl0_V1_I1_CB15_textBox

and

ctl00_ctl22_g_0faf3784_1c04_4644_8345_21a511739cfc_FormControl0_V1_I1_CB15

 

thanks!

Coordinator
Mar 14, 2012 at 5:16 PM

Hi,

is the combobox field a standard SharePoint field type ?

Just try it by trial and error.