Hi there,
I can spot three problems that might be stopping this working. One is capitalisation and another is not trimming - both might stop your comparison. The other is not deselecting the currently selected option. The JavaScript should probably be as follows: (I have changed
jQuery
to the recommended/proper use of
$
and changed
==
to recommended use of
===
)
$("a.preview_link").click(function()
{
var dropDownListItems = $(this).parent('p').find("select option");
var title = $(this).attr("title").trim().toLowerCase();
dropDownListItems.filter(":selected").removeAttr("selected");
dropDownListItems.filter(function()
{
return $(this).text().trim().toLowerCase() === title;
})
.first()
.attr("selected", "selected");
});
Hope this works/helps,
Ed