Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> add_line </title>
<Script language = "javascript" type = "text/jscript"> <! --
Function add_input_file (tbfile, index)
{
File_name = "file" + index;
Var tr_file = document. createElement ("tr ");
Var td_file = document. createElement ("td ");
Var input_file = document. createElement ("input ")
Input_file.setAttribute ("type", "file ")
Input_file.setAttribute ("size", "50 ")
Input_file.setAttribute ("name", file_name)
Td_file.appendChild (input_file)
Tr_file.appendChild (td_file)
Tbfile. appendChild (tr_file)
}
Function add_one_file ()
{
Var tb_file = document. getElementById ("upload_file ");
Var count_file = document. getElementById ("upload_file"). childNodes. length;
// Window. alert (steps_nums );
Add_input_file (tb_file, count_file );
}
// --> </Script>
</Head>
<Body>
<Div style = "text-align: center" style = "text-align: center">
<Form>
& Lt; table width = "90%" & gt;
<Tr>
<Td>
<BR/>
<BR/>
<H5> Configuration File Upload </Td>
</Tr>
<Tr>
<Td>
<Table id = "upload_file">
<Tr class = "tabletext">
<Td> <input type = "file" name = "job" size = "50"/> </td>
</Tr>
<Tr class = "tabletext">
<Td> <input type = "file" name = 'file2' size = "50"/> </td>
</Tr>
<Tr class = "tabletext">
<Td> <input type = "file" name = 'file3' size = "50"/> </td>
</Tr>
</Table>
</Td>
</Tr>
<Tr>
<Td align = "left">
<Input type = "button" value = "add a row" onclick = "add_one_file ()"/>
<Input type = "submit" value = "save"/>
<Input name = "ciname" value = "{ciname}"/>
<Input name = "type" value = "default"/>
</Td>
</Tr>
</Table>
</Form>
</Div>
</Body>
</Html>
Save all the Code as an html file, open it in the browser, and click "add a line". The following is an explanation of the js function.
Document. createElement creates a page tag
SetAttribute: Set attributes for a tag.
AppendChild: add a sub-tag to another tag.