When I press delete, nothing happens

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

08-Oct-17 01:42
Hi Friends , What I did wrong in this code that it does not work? the button appears when click on it nothing happens.. Thanks

$(document).ready(function() {
var p2_max_fields = 10; //maximum input boxes allowed
var p2_wrapper = $(".p2_input_fields_wrap"); //Fields p2_wrapper
var p2_add_button = $(".p2_add_field_button"); //Add button ID

var x = 1; //initlal text box count
$(p2_add_button).click(function(e){ //on add input button click
if(x < p2_max_fields){ //max input box allowed
x++; //text box increment
$(p2_wrapper).append('<div id="del-'+x+'" class="my_col col-md-12"><div class="col-lg-2"> <input placeholder="Description="p2_Description[]" class="form-control fullwidth " value="" ></div><div class="col-lg-2"> <input placeholder="ProtectionRequirments" name="p2_ProtectionRequirments[]" class="form-control fullwidth" value="" ></div><div class="col-lg-2"> <input placeholder="Done" name="p2_Done[]" style="margin-bottom:15px;" class="form-control fullwidth " value="" ></div><div class="col-lg-2"> <input placeholder="NotCarriedout" name="p2_NotCarriedout[]" class="form-control fullwidth" value="" ></div><div class="col-lg-2"> <input placeholder="Comments" name="p2_Comments[]" class="form-control fullwidth" value="" ></div><div class="col-lg-2"><a href="#" class="btn btn-danger" data-rel="'+x+'">Remove</a></div></div>'); //add input box .

$(wrapper).on("click",".remove_field", function(e){ //user click on remove text
var delx = $(this).attr("data-rel");
$('#del-'+delx).remove(); x--;

Mod note; code delimiters added

[Edited by chrishirst on 08-Oct-17 15:17]
08-Oct-17 15:20
In that code, .... .... Haven't got a clue.

Where is the rest of the code that is necessary to start testing???

So long, and thanks for all the fish.
09-Oct-17 01:27
Thank you Chris.

No Need clue more than that,
I fixed it


New posts
Old posts

Follow Elated