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
I have Tried something like this and its works fine;

this is the html part :
Year
:
Month
:
Week
:
Actual
:
Max
:
Target
:
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
- 热议问题