With JS wrote a dynamic insert row, each field is input, and the entire table is a form inside, with post submitted, seemingly cannot be submitted.
How do I get the value of each input of JS insert row?
Reply to discussion (solution)
form controls with the same name are named in array mode
So named.
What do you mean ' can't submit '? It is advisable to describe the problem carefully. It's best to put the code on it.
Post submission? Can't submit?
Are you using JS to submit? Paste the input Tag property to see if you are getting the value of the input property correctly.
What do you mean ' can't submit '? It is advisable to describe the problem carefully. It's best to put the code on it.
The code is more, please crossing slow look.
One: Dynamically add the line JS code
var index;
index = 1;
function InsertRow () {
var S1 = " ";
var s2 = " ";
var s3 = " ";
var S4 = " ";
var S5 = " ";
var s6 = " ";
var s7 = " ";
var s8 = " ";
var S9 = " ";
var s10 = "";
var table = document.getElementById (' table1 ');
row = Table.insertrow (index);
The/*insertrow () method is used to insert a new row at the specified position in the table.
Syntax Tableobject.insertrow (index)
The return value returns a TableRow that represents the newly inserted row.
Description
This method creates a new TableRow object that represents a new
tag, and insert it into the specified position in the table.
The new row will be inserted before the line of index. If index
is equal to the number of rows in the table, the new row is appended to the end of the table.
If the table is empty, the new row is inserted into a newSegment, the segment itself is inserted into the table.
num = document.getElementById ("tbl"). Rows.length;
R = Tbl.insertrow (num-2); Bottom line 2nd insert
Thrown
If the parameter index is less than 0 or greater than the number of rows in the table, the method throws a Domexception exception with the code INDEX_SIZE_ERR. */
Row.id = "TR" + index;
C1 = Row.insertcell (-1);//Insert Column TD, one insert, code write with innerHTML
c1.innerhtml = S1;
C2 = Row.insertcell (-1);
c2.innerhtml = s2;
C3 = Row.insertcell (-1);
c3.innerhtml = S3;
C4 = Row.insertcell (-1);
c4.innerhtml = S4;
C5 = Row.insertcell (-1);
c5.innerhtml = S5;
C6 = Row.insertcell (-1);
c6.innerhtml = S6;
C7 = Row.insertcell (-1);
c7.innerhtml = s7;
C8 = Row.insertcell (-1);
c8.innerhtml = S8;
C9 = Row.insertcell (-1);
c9.innerhtml = S9;
C10 = Row.insertcell (-1);
c10.innerhtml = S10;
}
function Delrow (index) {
var table = document.getElementById (' table1 ');
Table.deleterow (document.getElementById ("tr" + index). RowIndex);
This.index = this.index-1;
Two. Form content
Three. Submit page proinsert.php key code
if ($_post["Mysubmit"]== ' commit ') {
$exec = "Replace into profile (Id,enname,chname, Duty, Place,ephone,sec, Sphone, Olset, Olex,vpnex,tokenex,person,dtime)
VALUES
(' $_post[id] ', ' $_post[enname] ', ' $_post[chname ', ' $_post[duty] ', ' $_post[place ', ' $_post[ephone] ', ' $_post[sec ', ' $_post[sphone] ', ' $_post[olset] ', ' $_post[olex] ', ' $_post[vpnex] ', ' $_post[tokenex ' ', ' $_post[person ', ' Now () ');
if (!mysql_query ($exec, $con))
{
Die (' Database error hint: '. mysql_error ());
}
Header ("Location:detail.php?enname= $enname");
}
Mysql_close ($con);
innerHTML mode insertion In some browsers seems to be not recognized, it is recommended to change to appendchild way to insert, or directly with the jquery append () method to insert