SharePoint: Pre populate lookup field in NewForm.aspx using JQuery

Scenario: The list contains a single type Lookup field along with several other fields. This lookup field needs to be prepoulated with some value which is passed to the NewForm.aspx page using a query string. Given below is the sample code which reads the query string value of 'AccountReference' and uses this value to select the value of the lookup field named 'External Client Account'. Note that this name is the display name of the field which is rendered on the page.
$(document).ready(function () {    
    var dropDownValue = GetUrlKeyValue('AccountReference');
    if (dropDownValue) {
        $("select[title='External Client Account']").children("option").each(function () {
            if ($(this).text() == dropDownValue) {
                $(this).attr('selected', 'selected');
profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts