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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:17:25+00:00 2026-06-10T09:17:25+00:00

[+] //each time I click this button the textbox will generate and I want

  • 0

[+] //each time I click this button the textbox will generate and I want to have a link beside each textbox, link is “remove” when I click “REMOVE” the textbox will remove..

[hello1] Remove

[hello2] Remove

[hello3] Remove

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
var i=0,j=0;
var t1= new Array(); 
function createtext(){
  i++;
  t1[i]=document.createElement('input');
  t1[i].type='text';
  t1[i].name='text'+i;
  t1[i].value = "hello"+i;
  t1[i].size = 10;
  document.forms[0].appendChild(t1[i]);
  var mybr=document.createElement("br");
  document.forms[0].appendChild(mybr);
}
</SCRIPT>
</HEAD>
<BODY >
  <form action="" method="get" name="f1">

    <input name="b1" type="button" onClick="createtext()" value="+">

    <input name="b1" type="Submit"><br>

  </form>
</BODY>
</HTML>
  • 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-10T09:17:26+00:00Added an answer on June 10, 2026 at 9:17 am

    You can add a remove button along with the input tag like this:

    var i=0,j=0;
    var t1= [];
    
    function add(){
        i++;
        var parent = document.forms[0];
        var div = document.createElement('div');
        var input = document.createElement('input');
        input.type='text';
        input.name='text'+i;
        input.value = "hello"+i;
        input.size = 10;
        t1.push(input);
        div.appendChild(input);
        var removeButton = document.createElement("button");
        removeButton.innerHTML = "Remove";
        removeButton.onclick = function(e) {
            this.parentNode.parentNode.removeChild(this.parentNode);
            return(false);
        };
        div.appendChild(removeButton);
        parent.appendChild(div);
    }
    

    Working demo: http://jsfiddle.net/jfriend00/ky9nv/

    This code makes it easier to remove an input element and it’s associated button by enclosing them in a containing div. A clicked button can then just get it’s parent container and remove that.

    And, since your question is tagged with jQuery (thought it doesn’t save you a lot here), here’s a version that uses jQuery:

    var i=0,j=0;
    var t1= [];
    
    function add(){
        i++;
        var div = $('<div>');
        var input = $('<input>')
            .attr({
                size: '10',
                type: 'text',
                name: 'text' + i,
                value: 'hello' + i
            }).appendTo(div).get(0);
        t1.push(input);
        $('<button>Remove</button>')
            .click(function() {
                $(this).parent().remove();
            }).appendTo(div);
        $("#myForm").append(div);
    }
    
    add();
    add();
    
    $("#add").click(add);
    

    Working example: http://jsfiddle.net/jfriend00/nbXak/

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

Sidebar

Related Questions

I have this simple code each time i click the button its drawing a
Each time I click the Run as button, I get the following message. The
I'm just trying to run a new thread each time a button click even
How to each time when click Create New Poly button, store last object in
I have hard time to find textbox values in my repeater control. On button
Each time I click on the Reset button on my form. I get the
Each time I click on the map a new marker is placed on the
Each time I use Merge() I have the following: 'Cannot implicitly convert type 'void'
Each time my user signs in, we pull his profile picture from Facebook. This
Each time I make changes to XML file and press run button, It generates

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.