I have a dropdown with several in it. I am writing some jQuery to default to the of a logged in user. The problem is when some of my text is too similar.
//this variable gets the branch name of the logged in user
var branchName = $(".logged-in-branch-name").text();
//this makes the dropdown select the correct branch for the logged in user
$("#branchcode option:contains('" + branchName + "')").prop('selected', true);
This is all well and good. Except when text is to similar. Example:
"College 1" "College 1 - Online"
When the variable branchName is "College 1", the dropdown always defaults to "College 1 - Online".
When the variable is "College 1 - Online", it correctly goes to the "College 1 - Online" dropdown.
Any thoughts on how I can filter these correctly?
Thanks in advance.