Select Hide in HTML and display

Reprinted from the product is slightly Library  http://www.pinlue.com/article/2018/11/2303/047596163137.html

There is a case in html, if you want to hide the drop-down box of an existing page; but the problem is that the current page drop-down box to hide and show the default there, then the face of this situation may be that many people will think of an iframe to cover these drop-down box, so also, ah, but this can solve the current problem, but this seems not the final solution, the following is a drop-down box to hide and show a simple demo, see it.
Code is as follows:
<DOCTYPE the HTML the PUBLIC "- // // the DTD the HTML 4.0Transitional the W3C // EN"!>
<The HTML>
<the HEAD>
<TITLE> the NewDocument </ TITLE>
</ the HEAD>
<Script>
var the Array Array = new new (); // save is used to select elements displayed
// Select hidden elements
function hidden () {
var oSelect document.getElementsByTagName_r = ( "select"); // get all select
for (VARI = 0; I < oSelect.length; I ++) {
IF (oSelect [I] .style.display == "") {
Array.push (oSelect [I]); // put objects into an array
oSelect [i] .style.display = " none ";




function show(){
var oSelect = document.getElementsByTagName_r("select");//获得所有的select
for( var i=0;i<array.length;i++){
if(array[i].style.display){
oSelect[i].style.display="";
}
}
}
</script>
<BODY>
<selectname="test1">
<optionVALUE="1"SELECTED>宝马</option>
<optionVALUE="2">保时捷</option>
<optionVALUE="3"SELECTED>奔驰</option>
</select>
<select name="test2"style="display:none">
<optionVALUE="1"SELECTED>test01</option>
<optionVALUE="2">test02</option>
<optionVALUE="3"SELECTED>test03</option>
</select>
<select name="test3"style="display:none">
<OptionValue = ". 1" the SELECTED> test501 </ Option>
<OptionValue = "2"> test502 </ Option>
<OptionValue = ". 3" the SELECTED> test503 </ Option>
</ SELECT>
<selectname = "Test4">
< OptionValue = ". 1" the SELECTED> test601 </ Option>
<OptionValue = "2"> test602 </ Option>
<OptionValue = ". 3" the SELECTED> test603 </ Option>
</ SELECT>
<Button οnclick = "hidden (); "> hidden </ Button>
<buttonοnclick =" Show (); "> the Show </ Button>
</ the BODY>
</ the HTML>
this method is to hold an array js select display time of the last displayed again back array to display!

 

 

 

Published 60 original articles · won praise 58 · Views 140,000 +

Guess you like

Origin blog.csdn.net/yihuliunian/article/details/105384769