Dynamically add form elements to the classic code
[Html]
<Html>
<Head>
<Title> dynamically add form elements </title>
</Head>
<Script language = "javascript">
Function AddElement (mytype ){
Var mytype, TemO = document. getElementById ("add ");
Var newInput = document. createElement ("input ");
NewInput. type = mytype;
NewInput. name = "input1 ";
TemO. appendChild (newInput );
Var newline = document. createElement ("br ");
TemO. appendChild (newline );
}
</Script>
<Body>
<Form action = "" method = "get" name = "frm">
<Div id = "add">
<Input type = "text" name = "textfield">
</Div>
</Form>
<Input name = "" type = "button" value = "new text box" onClick = "AddElement ('text')"/>
<Input name = "" type = "button" value = "new check box" onClick = "AddElement ('checkbox')"/>
<Input name = "" type = "button" value = "Create a ticket" onClick = "AddElement ('Radio ')"/>
<Input name = "" type = "button" value = "New file domain" onClick = "AddElement ('file')"/>
<Input name = "" type = "button" value = "new password" onClick = "AddElement ('Password')"/>
<Input name = "" type = "button" value = "" onClick = "AddElement ('submit ')"/>
<Input name = "" type = "button" value = "new recovery button" onClick = "AddElement ('reset')"/>
</Body> www.2cto.com
</Html>
Author: Primary_wind