Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How can I make an additional form field appear whenever the user clicks a link without refreshing the page?

Each time the user clicks on a link one more textbox will appear.

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    <div id="textboxes">

    <input type="text" name="text1" />

    </div>

    <a href="#" onclick="return newtext()">Add New Textbox</a>

    <script type="text/javascript">

    var counter = 2;

    function newtext() {

    var div = document.getElementById('textboxes');

    var tb = document.createElement('input');

    tb.type = 'text';

    tb.name = 'text' + counter;

    div.appendChild(tb);

    counter++;

    return false;

    }

    </script>

    Customization is up to you.

    Edit: Please note that the person below me copied my answer.

Still have questions? Get your answers by asking now.