Use JavaScript to complete file operations, add new items to HTML control Select, read selected items in a Select control __mysql

Source: Internet
Author: User

The project needs to place a portion of the user's information everywhere at the client's designated location, requiring a specific disk root directory and taking some time to make an interface.

The Getdiskinfo () function is used to obtain the letter information and is added to the HTML control select.

The Exportkey () function is used to determine the location selected by the user and to write the information to the Userkey.txt file under that location.

< HTML >
< head >
< title > Export </title >
< SCRIPT language = "JavaScript" >
function Getdiskinfo ()
... {
var fso = new ActiveXObject ("Scripting.FileSystemObject");
var drives = fso. drives;
var e = new Enumerator (drives);
var selectinfo = document.getElementById ("SelectList");

for (;!e.atend (); E.movenext ())
... {
var anoption = document.createelement ("option");
Anoption.text = E.item (). Path;
Selectinfo.add (anoption);
}
}

function Exportkey ()
... {
var key = window.document.form1.<%= this. Userinfotextbox.clientid%>.value;
var fso = new ActiveXObject ("Scripting.FileSystemObject");
var e = new Enumerator (FSO. drives);
var path = Window.document.form1.selectlist.options[window.document.form1.selectlist.selectedindex].text + "/ Userkey.txt ";
for (var i = 0; i < (window.document.form1.selectlist.selectedindex-1); i++)
... {
E.movenext ();
}
if (E.item (). IsReady)
... {
F1 = fso. CreateTextFile (path, true);
F1. Write (key);
F1. Close ();
Alert ("Complete the export.") ");
}
Else
... {
Alert ("There is a problem with the storage location you have selected, please re-enter it.") ");
}
}
</script >
< body onload = "getdiskinfo ();" ms_positioning = "GridLayout" >
< form ID = "Form1" method = "post" runat = "server" >
< FONT face = "Song Body" >
< SELECT ID = "SelectList" style = "z-index:101;" left:8px; width:112px; Position:absolute; Top:8px ">
< option ></option >
</SELECT >
< INPUT onclick = "Exportkey ();" style = "z-index:102; left:128px; Position:absolute; top:8px "type =" button "value =" Export ">
< Asp:textbox ID = "Userkeytextbox" style = "z-index:103"; left:136px; Position:absolute; Top:64px "
                     runat = "Server"  height

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.