[Welfare] zosatapo
[Contact] dertyang@263.net
[Easy to explain] This article provides the dynamically generating SELECT options under the premise of not refreshing the page.
The current three programs are currently compared. And provide simple efficiency testing, web crew
According to yourself, you need to choose.
Due to time problems, I have not written articles, but I provide all the code I wrote.
I hope to have interested peers research.
The code should be written in detail.
Body {Font-Family: Courier New, Courier}
SELECT {font-size: 8pt; font-family: Courier New, Courier}
Input {font-size: 8pt; font-family: Courier New, Courier}
style>
VAR OPTTEXT = New Array (1000);
Var OptValue = New Array (1000);
Function Change (Object) {
OPT = Object.Options [object.selected ";
Alert (OPT.Value ":" OPT.Text);
}
For (i = 0; i { Opttext [i] = "zostapo" i; OptValue [i] = "name" i; } Function option () { VAR OPT; Var Start; Var end; Start = new date (); SelContainer.innerhtml = ""; SelContainer.innerhtml = " For (i = 0; i {OPT = New Option (); // Or You May Code Like Below: //opt=document.createElement ("Option "); Opt.text = OPTTEXT [I]; Opt.Value = OptValue [i]; Selshiow.Options.Add (OPT); } End = new date (); Optiontime.innertext = "The Operation TOOK TIME:" (end.gettime () - start.gettime ()) "MilliseConds"; Function Object () { Var Start; Var end; Var str = " Start = new date (); SelContainer.innerhtml = ""; For (i = 0; i { Str = " } SelContainer.innerhtml = " End = new date (); Jointime.innertext = "The Operation TOOK TIME:" (end.gettime () - start.gettime ()) "MilliseConds"; } // -> Script> HEAD> Dynamic Generating SELECT Option Demo Daquan font> b> p> Method i: Options.add () font> test span> Method i: Object.innerhtml font> >>>>>>>>>> test span> Method i: Object.innerhtml & array.join () font> test span> demonstrate the effect of the preview area: font>
span> Body> Html>