1. The basic idea
(1) How to "copy"?
As shown in the figure above, if you want to add a new row on or below on a row of the table, and to ensure that all tags in the cell are generally used by Clone. However, it is found that the Clone method has a higher IE requires 6.0, so I abandon this method, give the newly increased cells to achieve the "copy" effect by obtaining HTML in each cell. Take HTML will encounter a problem, that is, if the value value exists in the tag, then take it out. Obviously, we hope that the new bank does not have initial values, so when you increase the line, I give all the text boxes of the new row to null, radio boxes, and checkboxes become non-selection status, and pull down the box Select the first one.
(2) Radio's Name (Name) problem
Whether using Clone or "copy" HTML method, Radio's naming is a problem, because we want Radio in each cell into a group, while Clone and "Replication" HTML will copy the name of Radio and copy it. Thus such the original Radio and the new Radio have the same NAME, it will be constrained when entering it. If you only find new Radio and give it a Name value, you must clearly give the cell HTML content, which must contain the Name value of Radio, so that "copy" HTML method is a bit stupid Here, it is still sent to the field ^ _ ^. We can get the original HTML content, how to change its name? Find the Name value of the original Radio, replace it in the newly added HTML to another name. Since this name is just to group the RADIO, you can replace the random number, I use time.
(3) How to give Name to the label in the form
Obviously, we must get the values of each label, which must know the label Name. When the form is submitted, you need to give an initial Name value, then assign a value to the label of each line according to this initial value, for example, if the user settings the input text box name, all input text The frame of the frame will become: txt_0, txt_1, txt_2 ...... .. At this time, you can rest assured Radio's stubborn, although it is not possible to make its input valid by changing the attribute value of Name, but there is no impact on the dazzle of the background, if people are willing. In addition, to get the value of all tags, you must have a number of items, of course, will provide a function.
2. Limitations of procedures
The format of the table must be similar to the figure, the program wants to do not need to dynamically operate, and the specified label is not included in the line (such as the first, second lines), the specified label is INPUT, TEXTAREA, SELECT, but also supports dynamic operation. label. If you want to support more labels, you can modify the program. However, it is generally enough. In addition, it is not desirable that this fixed row appears at the end of the table. Moreover, the last column of the table must be added, deleted buttons. Although there are so many limitations, it is no problem to deal with general applications.
3. Source code and document download
Http://pickup.mofile.com/2430794466054426