php - jQuery Unable to process cloned input fields -


i have code clone input field directly preceding clone 'button' renaming id , name of field goes (shown below): -

$(".clone").live('click', function () { var doppleganger = $(this).prev(); // neater referencing.     $(doppleganger).clone().insertafter(doppleganger);  $(this).prev().attr("id", "input" + increment).attr("name", "input" + increment);      increment++;  return false;  }); 

. form (#adv_magic) data loaded on fly jquery ajax event , submitted thusly: -

$("#adv_magic").live('submit', function() {  $("#editor_button, #date_select, #search").hide(); $(".loader").show();  $.ajax({     type: "post",     url: "./scripts/aquire_template.php",     data: $("#adv_magic").serialize(),     success: function(html){         $("#right_container").empty();         $(".loader").fadeout(350);             $("#right_container").html(html);     } }); return false;  }); 

however cloned input fields not being processed when form posted script. i've seen few tutorials creating input fields array i'd rather not mess around @ stage if there else can do.

i'm wondering if it's way serializing form? can't post full code or link on occasion unfortunately application not available web. thoughts on appreciated! i'm stumped!

update sat 10th 20:31 gmt > got following report console > post tab in firebug: -

input1  meeting input2  select date input3  enter text input5  number missing input6  enter text input7  test switch  1  source input1=meeting&input2=select+date&input3=enter+text&input6=enter+text&input7=test&input5=number+missing&switch=1 

inputs 5/6/7 cloned elements presumably being passed script?

update sat 10th 21:06 gmt > echoing string variable before being processed script shows non of cloned input fields.

this 1 worked me.

<form id="myform">     <fieldset>         <input type="text" id="input1" name="input1"/><input type="button" value="clone" class="clone"/>     </fieldset>     <input type="submit" value="submit" id="sbmt"/> </form>   $(".clone").live("click", function(e) {     var count = $("#myform fieldset").length + 1;     $(this).parent().clone().insertbefore("#sbmt").find("input[type=text]").attr({         "id": "input" + count,         "name": "input" + count     }).val(""); });   $("#myform").submit(  function(e) {     e = e || window.event;     e.preventdefault();      $.ajax({         type: "get",         url: "/",         data: $("#myform").serialize(),         success:function(data){         }     });     return false;  }); 

demo: http://jsfiddle.net/wfzx5/2/


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -