You are viewing limited content. For full access, please sign in.

Question

Question

Select a value from a drop down list that is being filled by a lookup condition

asked on February 16, 2015

Hi There

 

I have a form(As per img1 attached) that has a Table with 2 columns in it, One is  "department "(Drop Down Field) and the other is "filledField"( single line field).

 

The Drop Down field is being filled via a lookup Rule(no condition, just a fill). This is from a MSQL database with all the departments listed here. The filledField is also a lookup rule but will only return 1 result based on the condition rule.

When the filled column is populated with data , the Drop Down list should auto select the matching value. 

 

I have attached the code i am using. The strange thing is that this code works if the Drop Down list is not a lookup value i.e. the drop down options are set when creating the drop down field(As per img2 attached).

$(document).ready(function () {
$('.cf-table-block').change(grabVal);
});



function grabVal() {
$('.cf-table-block tbody tr').each(function () {
  
   var s = $(this).find('.filledField input').val();
   
$('.dropDown').find('Option[value="' + s + '"]').prop('selected', true);
})
}

Not sure how to make the drop down select the correct value when it has a lookup rule.

Any Ideas Please?

Reagrds

 

Farren

img1.png
img2.PNG
img1.png (199.02 KB)
img2.PNG (21.11 KB)
0 0

Answer

SELECTED ANSWER
replied on February 16, 2015

Hi Farren,

 

Give this a try:

 

$(document).ready(function () {
$('.filledField').change(grabVal);
});



function grabVal() {
  
    var s = $('.filledField input').val();  
   
    var a = '';
    a = $('.dropDown option').filter(function () { return $(this).html() == s; }).prop('selected', true);
    

}

It seems that the Forms engine generates different HTML for a Drop-Down populated by a Lookup as opposed to the same Drop-Down manually populated. For example:

 

Drop-Down populated with a lookup:


<select id="Field7" class="form-item-field cf-medium user-success" vo="e" name="Field7">
<option></option>
<option>Admin</option>
<option>Assembly</option>
</selected>

Drop-Down populated manually:

<select id="Field9" class="form-item-field cf-medium" vo="e" name="Field9">
<option></option>
<option value="Admin">Admin</option>
<option value="General">General</option>
<option value="Management">Management</option>
</select>

Notice how the "value" attribute is missing from the lookup populated Drop-Down. This means that JQuery cannot find the value you're searching for using the same code that works for the manually populated Drop-Down.

 

Regards,

Sheldon

1 0
replied on February 16, 2015

Thanks Sheldon, makes 100% sense and it is working

You are a rock star!

0 0

Replies

You are not allowed to reply in this post.
replied on January 4, 2017 Show version history

Can anyone provide the c# code to add a new value to an existing List using the sdk.

 

Thanks

You are not allowed to follow up in this post.

Sign in to reply to this post.