Set option 'selected' in select form by text using jQuery
The code below is my solution in creating a custom SharePoint List form. The list has a lookup column, the column is filled with Name (Fullnames) of employees. The task is to mark option with user Name as selected. Variable 'user' is equal to Name of employee.
The Javascript with jQuery code below:
$("select[title='Coach'] option").each(function() {
if($(this).text() == user) {
$(this).prop('selected', true);
}
});
A Hidden Visual Studio Trick: Execute Selected Code with double Ctrl+E
What do to with Zone.Identifier files after importing a WSL machine and copying data
Support for SharePoint Server 2019 ends on Tuesday, July 14, 2026