Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4241134
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:15:48+00:00 2026-05-21T03:15:48+00:00

I have a textbox whose id is other and I want to populate this

  • 0

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:-
http://viralpatel.net/blogs/demo/dynamic-combobox-listbox-dropdown-in-javascript.html

<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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T03:15:49+00:00Added an answer on May 21, 2026 at 3:15 am

    I believe its because

    var textb = $('#other').attr('id');
    var combo = $('#category').attr('id');
    

    Aren’t you assigning id’s of these elements to variables, instead of elements?
    I mean… is textb really a input element after this code executes, or is it just a string “other”?

    Try this:

    var textb = $('#other');
    var combo = $('#category');
    

    Edit:

    function addCombo() {
        var textb = document.getElementById("other");
        var combo = document.getElementById("category");
    
        var option = document.createElement("option");
        option.text = textb.value;
        option.value = textb.value;
        try {
            combo.add(option, null); //Standard 
        }catch(error) {
            combo.add(option); // IE only
        }
        textb.value = "";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox whose value I want to set based on the inner
I have a text box on a web page, whose value I want to
I have a TextBox whose value is passed to an int property in an
I have TextBox (multiline) and Label in an UpdatePanel which I refresh with javascript
I have a TextBox and a Popup control. I want the Popup.IsOpen property to
I have a textbox.In its onclick iam calling a javascript fn to call calendar.Texbox
I have asp:TextBox to keep a value of money, i.e. '1000', '1000,0' and '1000,00'
I have a textbox that I would like for only numbers. But if I
I have a form with several textboxes and other controls. I'm using the errorprovider
I have a dynamically created (runtime creation) textbox whose name is available as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.