Results 1 to 2 of 2

Thread: add more field

  1. #1
    Join Date
    Jun 2010
    Posts
    243

    add more field

    i would like a form that has one repetative field. if the user would like to enter more of the fields (ex. files) , they click on a button to show more fields.

  2. #2
    Join Date
    Apr 2011
    Posts
    36
    Hy,
    Try test and use this example.
    The user can add text-fields, but you can replace it with type="file"
    Code:
    <script type="text/javascript">
    <!--
    // - www.coursesweb.net/javascript/
    // creates an input element and adds it before the Submit button
    function add_input() {
        var new_input = document.createElement("input");
        new_input.setAttribute("type", "text");
        new_input.setAttribute("name", "nume[]");
        new_input.style.display = 'block';             // Seteaza display:block; pt. a afisa casutele unele sub altele
    
        // sets the objects for reference (reper) and parent
        var reper = document.getElementById('submit');
        var parinte = reper.parentNode;
    
        // Adds the new element
        parinte.insertBefore(new_input, reper);
    }
    //-->
    </script>
    
    <form action="">
        <input type="text" name="nume[]" />
        <input type="submit" value="Submit" id="submit" /><br /><br />
        <input type="button" value="Add field" onclick="add_input()" />
    </form>

Similar Threads

  1. Text field
    By SteveJo in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 20 Oct 2010, 09:48 AM
  2. form field to databse help.
    By greenelephant in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 03 Aug 2009, 04:41 PM
  3. Drupal: how to add a field of content to the sidebar(a block)
    By needesigner.com in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 22 May 2009, 05:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •