Populate Drop Down List using jquery mobile from textbox
I have a textbox whose id is other and I want to populate this textbox value into drop down list
This is javascript I am using to populate... but this is not working.. Any suggestion will be appreciated...!! I want to do like this:-
- <SCRIPT language="javascript">
- function addCombo() {
- var textb = $('#other').attr('id');
- var combo = $('#category').attr('id');
- alert(combo);
-
- var option = document.createElement("option");
- option.text = $('#other').val();
- alert(option.text);
- option.value = $('#other').val();
- try {
- combo.add(option, null); //Standard
- }catch(error) {
- combo.add(option); // IE only
- }
- textb.value = "";
- }
- </SCRIPT>
------------------------------------------------------------------------------
This is the code of drop down list
- <td>Category</td>
- <td><select class="size" id="category" name="category" width="30px">
- <option width="30px" value="" selected="selected" >Select</option>
- <option value="food">Food</option>
- <option value="rent">Rent</option>
- <option value="gas">Gas</option>
- <option value="enter">Entertainment</option>
- <option value="grocery">Grocery</option>
- <option value="general">General</option>
- <option value="other">Other</option></select></td>
- </tr>
- <tr>
- <td>Other</td>
- <td><input type="text" id="other" name="other"/></td>
- <td><input type="button" data-role="button" value="Add" onclick="addCombo()"></td>
- </tr>