Adding rows dynamically with jQuery

前端 未结 5 1002
天命终不由人
天命终不由人 2020-11-28 02:48

I\'m building a form where I need multiple optional inputs, what I have is basically this:

Every time a user presses the plus button a new row of form inputs

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 03:21

    I have Tried something like this and its works fine;

    enter image description here

    this is the html part :

    this is Javascript part;

    
    
    

    Finaly PHP submit part:

        for( $i = 1; $i <= $count; $i++ )
    {
        $year = $_POST['year'.$i];
        $month = $_POST['month'.$i];
        $week = $_POST['week'.$i];
        $actual = $_POST['actual'.$i];
        $max = $_POST['max'.$i];
        $target = $_POST['target'.$i];
        $extreme = $_POST['extreme'.$i];
        $que = "insert INTO table_name(id,year,month,week,actual,max,target) VALUES ('".$_POST['type']."','".$year."','".$month."','".$week."','".$actual."','".$max."','".$target."')";
        mysql_query($que);
    
    }
    

    you can find more details via Dynamic table row inserter

    提交回复
    热议问题
    Year : Month : Week :    
    Actual : Max : Target :