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

  • Home
  • SEARCH
  • 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 6699305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:40:47+00:00 2026-05-26T06:40:47+00:00

I have a text input with a button. When I fill in the input

  • 0

I have a text input with a button. When I fill in the input and click the button I want to add that information to a select. Please can anyone one help, I can’t find an example anywhere.

Input & button
<input id="new_menu_name" type="text" name="new_menu_name" placeholder="Please enter your menu title">
<input class="add_menu_item" name="add_menu_item" value="Add" type="button">

Select
<select name="menu_items" id="menu_items" size="8" multiple="multiple" style="height:200px; width:250px;">      
</select>

I have tried using this script but with no luck

$(document).ready(function() {
    $(".add_menu_item").click(function(){
 $('#menu_items').
      append($("<option></option>").
      attr("value").
      text(value)); 
    });

JSfiddle
http://jsfiddle.net/clintongreen/XDqQL/

  • 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-26T06:40:48+00:00Added an answer on May 26, 2026 at 6:40 am

    When you call attr, you’re not actually setting a value: you’re retrieving the current value of the value attribute. You should use the val function to set the value:

    $(".add_menu_item").click(function () {
        $('#menu_items').append(
            $("<option></option>").val(value).text(value)
        );
    });
    

    Now that I’ve seen your full code, it’s clear that the other problem is that you aren’t setting the value variable. I think you probably want something like this:

    $(".add_menu_item").click(function () {
        var value = $(this).prev().val();
        $('#menu_items').append(
            $("<option></option>").val(value).text(value)
        );
    });
    

    (NB also that I’ve changed the fiddle to use jQuery rather than Mootools.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one text input and one button (see below). How can I use
I would like to have a text input form with a submit button that
I have a text input field like text box or text area. I want
I have a button on a form that is dynamically spawning a select list,
i have a form element- text input and a submit button- Im trying to
I have text input boxes. There is validation for each of the boxes using
I have a text input : <input type=text onkeydown=processText(this) /> I have a processing
I have the following text input on a budget calculator form which displays the
Newbie question... The objective: I intend to have an HTML text input field as
I have this input text: <html><head><meta http-equiv=content-type content=text/html; charset=utf-8></head><body><table cellspacing=0 cellpadding=0 border=0 align=center width=603>

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.