How to submit js insert row data

Source: Internet
Author: User
How to submit js insert row data write a dynamic insert row with js, each field is input, and the entire table is in form, submit with post, it seems that cannot be submitted.
How can we get the value of each input in the js insert row?


Reply to discussion (solution)

The form control with the same name must be named using arrays.

In this way.

What is 'cannot submit '? We recommend that you carefully describe the problem. You 'd better paste the code.

Post submission? Cannot submit?
Are you submitting with js? Paste the input tag attribute to see if you have correctly obtained the value of the input attribute.

What is 'cannot submit '? We recommend that you carefully describe the problem. You 'd better paste the code.



There are a lot of code. please take a look at it slowly.

I. dynamically add lines of 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 a specified position in the table.
Syntax tableObject. insertRow (index)
Return a TableRow value, indicating the newly inserted row.
Description
This method creates a new TableRow object, indicating a new
And insert it into the specified position in the table.
The new row will be inserted before the row where the index is located. If the index
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, which is itself inserted into the table.
Num = document. getElementById ("tbl"). rows. length;
R = tbl. insertRow (num-2); // Insert the last 2nd rows
Throw
If the index is smaller than 0 or greater than or equal to the number of rows in the table, this method throws a DOMException code INDEX_SIZE_ERR. */
Row. id = "tr" + index;
C1 = row. insertCell (-1); // Insert column td, insert one by one, and write code 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;


II. FORM content


3. submit the key code of proinsert. php on the page
If ($ _ POST ["mysubmit"] = 'submit '){
$ 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 prompt: '. mysql_error ());
}

Header ("Location: detail. php? Enname = $ enname ");
}
Mysql_close ($ con );

The innerHTML method does not seem to be recognized in some browsers. we recommend that you use the appendChild method or the jquery append () method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.