How to pass an array of checked/unchecked checkbox values to PHP email generator?

前端 未结 5 1673
眼角桃花
眼角桃花 2020-12-05 22:04

I have added a checkbox to a form that the user can dynamically add rows to. You can see the form here.

I use an array to pass the values for each row to a PHP emai

5条回答
  •  悲&欢浪女
    2020-12-05 23:00

    Change the value for each checkbox to something unique:

     
     
    

    etc. In order to do this from your jQuery code, add another line that assigns the value to the new checkbox:

    x.find('input:checkbox').each(function() { this.value='Yes-'+n; }); 
    

    You'll have to define n on the initial page load. Assuming you start with only one "person", just add right above your $(".add").click handler:

    var n=1;
    

    And then:

    • in your $(".add").click handler, increment the value of n
    • in your $(".remove").click handler, decrement the value of n

提交回复
热议问题