Jump to content

Generating textbox's - Need help getting name


slj90

Recommended Posts

I have a form which allows users to add textboxes but I am struggling figuring out what the name of the new textbox's are?

 

 

$(document).ready(function() {
    var max_fields      = 10; //maximum input boxes allowed
    var wrapper         = $(".input_fields_wrap"); //Fields wrapper
    var add_button      = $(".add_field_button"); //Add button ID
    
    var x = 1; //initlal text box count
    $(add_button).click(function(e){ //on add input button click
        e.preventDefault();
 
        if(x < max_fields){ //max input box allowed
            x++; //text box increment
 
            $(wrapper).append('<div><input type="text" onclick=" class="form-control" name="list[]"/><a href="#" class="remove_field">Remove</a><br></div>'); //add input box
        }
    });
    
    $(wrapper).on("click",".remove_field", function(e){ //user click on remove text
        e.preventDefault(); $(this).parent('div').remove(); x--;
    })
});
</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.