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 8356963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:20:25+00:00 2026-06-09T10:20:25+00:00

I have a single text field and an accompanying add button: <fieldset id=itemList> <input

  • 0

I have a single text field and an accompanying “add” button:

<fieldset id="itemList">
    <input type="text" id="addItem" name="addItem">
    <input type="button" name="add" value="add">
</fieldset>

Whenever someone clicks “add” I’d like to add the new item to the list below and clear the input field above.

<hr>
<ol id="resultList">
    <li>just example</li>
    <li>new text input</li>
    <li>last entered item</li>
</ol>

I’m not sure how to accomplish this in jQuery. Can you help?

For bonus, I’d like to limit the list to 10. So I need to somehow count the number of list items and make the above form’s display contingent on <11 list items.

Can you help?

  • 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-06-09T10:20:29+00:00Added an answer on June 9, 2026 at 10:20 am
    jQuery(function($){
        $('input[name="add"]').click(function() {
            if($('#resultList li').length < 10)
            {    value = $('input[name="addItem"]').val();
                 $('ol li:last').after("<li>" + value + "</li>");
                 $('input[name="addItem"]').val(""); }
            if($('#resultList li').length == 10)
            {   $('input[name="addItem"]').css("display", "none");
                $('input[name="add"]').css("display", "none"); }
        });
    });
    

    Working jsFiddle here: http://jsfiddle.net/bhZdz/2/

    Edited because I didn’t see the last part of your question, form hides after 10th element is added now.

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

Sidebar

Related Questions

I have created a settings bundle with a single preference value, a text field
I have a feed that is populating a single text field in a table
i have a table with single row (textfield) and Add Row button, when user
I have a very simple voting form. It contains a single text field for
I have a MySQL table with just a single text type column with lots
I have a search field, and using that single text box I want the
I have a form which has a search feature - a single text field
I have created a text field component with an 'x' button inside that will
I have a single big text file in which I want to process each
I have text documents like the following which contain single and multiple variables: title::

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.