Code-Basics for dynamically generating page elements

Source: Internet
Author: User
The first one:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" > <ptml> <pead> <title>untitled document</title> <meta http-equiv= "Content-type" content=; charset=gb2312 "> <script language=" JavaScript > <!--function addinputfile (Spanid,fileid) { var span = document.getElementById (Spanid); if (span!=null) {if (Navigator.userAgent.indexOf ("msie") = = 1) {var fileobj = document . createelement ("input"); if (fileobj!= null) {fileobj.type= "file"; Fileobj.name = Fileid; Fileobj.id = Fileid; Fileobj.size= "50"; Span.appendchild (Fileobj); }//if fileobj fileobj = document.createelement ("BR"); if (fileobj!= null) {span.appendchild (fileobj); } else{var filetag = "<input type= ' filE ' id = ' "+ Fileid +" ' name= ' "+ Fileid +" ' size=50> "; var fileobj = document.createelement (Filetag); Span.appendchild (Fileobj); Filetag= ""; Fileobj = Document.createelement (Filetag); Span.appendchild (Fileobj); }//if span}//--> </script> </pead> <body> <form name= "Form1" Method= "POST" action= "" > <input type= "button" name= "button" value= "Add File" onclick= "Addinputfile (' fileName ', ' Bao Bao '); " > <span id= "fileName" ></span> </form> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]




The second one:

<textarea id="runcode21640"><script> function Deloption (e) {e.previoussibling.value= ""; E.previoussibling.removenode (); E.nextsibling.removenode (); E.removenode (); function AddOption (name) {var Newtextarea = document.createelement (' <textarea name= "qoption" ></textarea> ;') var Newbutton = document.createelement (' <input type= "button" onclick= "Deloption (This)" value= "delete" > "); var newbr = document.createelement (') var parentnode=document.all[name]; Parentnode.appendchild (Newtextarea); Parentnode.appendchild (Newbutton); Parentnode.appendchild (NEWBR); } </script> <input type= "button" onclick= "addoption (' option ')" value= "Add" > <span id= "option" ;</span></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.