couldn't pass value from textbox to select input
<p>In my code, I have following lines to get the value from textbox input and set one of options as selected in select input according to this value.</p>

<pre><code>var category_name = jQuery('.categoryNameTextbox').val();    

//alert(category_name);

jQuery('.categoryDropdown').val(category_name);
</code></pre>

<p>I can get "category_name" successfully, but I couldn't set the option in select input. However, if I use the following line to test, i can set "rent" as selected option in select input perfectly.</p>

<pre><code>jQuery('.categoryDropdown').val("rent");
</code></pre>

<p>Anyone knows what is going on here? Thank you in advance.</p>

<p>Here is my code. My purpose is set selected option in dropdown list according to the value in the textbox</p>

<pre><code>&lt;select class="categoryDropdown"&gt;&lt;option value=""&gt;Select&lt;/option&gt;&lt;option value="buy"&gt;Buy&lt;/option&gt;&lt;option value="sell"&gt;Sell&lt;/option&gt;&lt;option value="rent"&gt;Rent&lt;/option&gt;&lt;/select&gt;&lt;div style="display: none;"&gt;&lt;input type="text" class="categoryNameTextbox" value="rent"&gt;&lt;/div&gt;
</code></pre>
