Change style of text field based on the selection of a combo box using Javascript
<p>I would like to change the style of a text field based on the value selected in a combo box.  Specifically, what I'd like to do is make the txtDepartment field gray and marked as "read only" if the option value selected in cboSource is 1.  I've tried the code below, but I imagine my style code at least is wrong, if not other things.  Any help appreciated.  Thanks!</p>

<pre><code>&lt;select name="cboSource" id="cboSource" onClick="displayDepartment(this);"&gt;
    &lt;option value = 1&gt;Source 1&lt;/option&gt;
    &lt;option value = 2&gt;Source 2&lt;/option&gt;
&lt;/select&gt;

&lt;input name="txtDepartment" type="text" id="txtDepartment" size="6" maxlength="6"&gt;&lt;/p&gt;

&lt;script&gt;
function displayDepartment(obj)
{
    var selectedValue = obj.value;
    var txtDepartment = document.getElementById("txtDepartment");


    if (selectedValue == "1") 
    {
        txtDepartment.style.display = "Disabled style='background-color:#E8E8E8'";

    }
}
&lt;/script&gt;
</code></pre>
