Kevin
var INV = $('#view_218-field_184').text();
var data = {
field_279: INV
};
Hi Brad,
Many thanks for the link - will keep you updated :)
Check out this post Kevin https://support.knack.com/hc/en-us/community/posts/360019026412-Select-Default-Dropdown-on-Page-load-Javascript
I reckon Sunny posted some methods here.
This is not correct but illustrates my current thinking :)
$('#field_281 option').map(function () {
if ($(this).val() == INV) return this;
}).attr('selected', 'selected');
Hi Brad,
I am currently looking at doing something similar to this https://studentboxoffice.in/dotnet/article/4/119
With the value of #field_281 set to the value of INV or field 146. - still very early days :)
Hey Kevin, what have you tried so far mate?
Hi Brad,
You have been super helpful, but I have one more question;
If looking to update a (single select) connection field, how would one go about setting the value of the connected field to the same value as INV or field_146 (the connected field contains an identical value as one of the select options) ?
Hi Brad,
Works like a charm - you are an absolute legend :)
Many Thanks
Kevin
Your code to set the variable INV will result in 'undefined' as it's not properly formed JQuery.
Try using the data variable returned from the view-render:
INV = data.field_146;
Notice you don't need to re-initialise the variable with the var statement either.
Next step would be to check your variables work along the way with judicious use of console.log() statements - check out this for help on debugging JS https://www.w3schools.com/js/js_debugging.asp
Hi Brad,
Hi Kevin,
Is what you're doing not working? Is INV undefined?
Another option is to grab the data on scene-render (happens after all the views are rendered) using the Knack.models method.
E.g.
var INV = Knack.models['view_218'].toJSON().field_184;