I have a couple of lookup controls on a form. The default behavior is to have some text that displays, "Please select a value...". My users want me to default to the first item in the list. Through searching the community site, I found that there isn't a property I can set and that I would have to do something via Javascript.
When I do the code to select the control, I get an error trying to set a value to the first one. Through some investigation, it appears that Nintex Forms renders a SELECT and and INPUT with the same ID. When you do a select through the javascript $NWF("#" + ddlShipVia), the type of control that comes back is INPUT, not SELECT. When I look at the HTML source, I see the following structure for a lookup.
<div formcontrolid="4af0658e-cbbc-438d-afbe-c27a2ad8068e"
data-controlname="ShipVia"
data-uniqueid="c0a89c70-0781-4bd4-8623-f73675005e15"
data-controlid="4af0658e-cbbc-438d-afbe-c27a2ad8068e"
data-formcontroltypeid="c0a89c70-0781-4bd4-8623-f73675005e15"
data-enabled="True">
<div class="nf-filler-control-border">
<div class="nf-filler-control-inner">
<div>
<span id="ctl00_ctl41_g_91b5f1e3_92bd_4d83_8d14_a26b5dce3b8d_ctl00_ListForm2_formFiller_FormView_ctl06_ctl40_ctl28_lookup4f2e3949_0f86_425e_b950_d0251de74300"
title="{help text}">
<div class="nf-lookup-loading nospinner" data-bind="css: { nospinner: hideLoadingSpinner }, visible: isLoading" style="display: none;">Loading...</div>
<select
id="ctl00_ctl41_g_91b5f1e3_92bd_4d83_8d14_a26b5dce3b8d_ctl00_ListForm2_formFiller_FormView_ctl06_ctl40_ctl28_lookup4f2e3949_0f86_425e_b950_d0251de74300_Lookup"
formcontrolid="4af0658e-cbbc-438d-afbe-c27a2ad8068e">
<OPTIONS>.......</OPTIONS>
</select>
<input name="ctl00$ctl41$g_91b5f1e3_92bd_4d83_8d14_a26b5dce3b8d$ctl00$ListForm2$formFiller$FormView$ctl06$ctl40$ctl28$lookup4f2e3949_0f86_425e_b950_d0251de74300$Lookup"
type="text" id="ctl00_ctl41_g_91b5f1e3_92bd_4d83_8d14_a26b5dce3b8d_ctl00_ListForm2_formFiller_FormView_ctl06_ctl40_ctl28_lookup4f2e3949_0f86_425e_b950_d0251de74300_Lookup" ...>
<br>
</span>
</div>
</div>
</div>
</div>
How do I select the "SELECT" control if the ID on the SELECT and INPUT are the same?
I tried to iterate through the options by using $NWF("#" + ddlShipVia > OPTION) but I get an error that there is no OPTION. It's true because the type of control that is returning from the jQuery selection is an INPUT.
Any ideas?