當前位置:首頁 » 網頁前端 » web下拉列表
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

web下拉列表

發布時間: 2022-01-30 12:29:51

㈠ web自動化,下拉框處理

web中的下拉框selenium處理基本的定位option的方式,還提供了Select類來進行操作
方式一:
1.定位option選項,進行點擊
方式二:
通過Select類實現
from selenium.webdriver.support.select import Select
select = Select(driver.find_element_by_id("selectA")) # 通過select標簽生成Select對象
select.select_by_index(index) # 通過索引獲取option
select_by_value(value) # 根據option屬性 value值來定位
select_by_visible_text(text) # 通過option標簽中的顯示文本獲取
以前在黑馬程序員培訓後,也會買他們出版的書,這個就是直接從書上看的。現在很多大學都用的他們的教材,我就會沒事看看。反正說的挺詳細的。

㈡ java web怎麼實現下拉菜單

這個很好實現,在後台進行查詢,查詢到所有的菜單id和name以及其他的數據,後返回主頁面,再有jstl表達式遍歷出來,或者c標簽的foreach標簽直接遍歷就ok了

㈢ CSS網頁下拉列表大小怎麼調整

需要准備的材料分別有:電腦、瀏覽器、html編輯器。

1、首先,打開html編輯器,新建html文件,例如:index.html。

㈣ 網頁設計關於下拉列表的代碼

看看這個不錯:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Untitled Document</title>
<script language="JavaScript" type="text/javascript">
//---------------------------------------------------------------------------
// 功能搜索選擇框
// 作者:Joshua
// 創建時間:2007-02-07
// Email:JoshuaChen[at]126.com
// webSite:www.x.cn
//---------------------------------------------------------------------------
//省
var Data_Area_Province = new Array("安徽","北京","福建","甘肅","廣東","廣西","貴州","海南","河北","河南","黑龍江","湖北","湖南","吉林","江蘇","江西","遼寧","內蒙古","寧夏","青海","山東","山西","陝西","上海","四川","天津","西藏","新疆","雲南","浙江","重慶");
//市區
var Data_Area_City = new Array();
Data_Area_City[0] = new Array("安慶","蚌埠","馬鞍山","宿州","銅陵","蕪湖","宣城","亳州");
Data_Area_City[1] = new Array("北京");
Data_Area_City[2] = new Array("福州","龍岩","南平","寧德","莆田","泉州","三明","廈門","漳州");
Data_Area_City[3] = new Array("白銀","定西","天水","武威","張掖");
Data_Area_City[4] = new Array("潮州","東莞","佛山","廣州","肇慶","中山","珠海");
Data_Area_City[5] = new Array("百色","北海","崇左","防城港","桂林","貴港","河池","賀州","來賓","柳州","南寧","欽州","梧州","玉林");
Data_Area_City[6] = new Array("安順","畢節","貴陽","六盤水","銅仁","遵義");
Data_Area_City[7] = new Array("白沙黎族自治縣","樂東黎族自治縣","萬寧","文昌","五指山","儋州");
Data_Area_City[8] = new Array("保定","滄州","承德","邯鄲","衡水","廊坊","秦皇島","石家莊","唐山","邢台","張家口");
Data_Area_City[9] = new Array("安陽","鶴壁","濟源","焦作","開封","洛陽","周口","駐馬店","漯河","濮陽");
Data_Area_City[10]= new Array("大慶","大興安嶺","哈爾濱","鶴崗","七台河","齊齊哈爾","雙鴨山","綏化","伊春");
Data_Area_City[11] = new Array("鄂州","恩施土家族苗族自治州","黃岡","襄樊","孝感","宜昌");
Data_Area_City[12] = new Array("常德","長沙","岳陽","張家界","株洲");
Data_Area_City[13] = new Array("白城","白山","長春","吉林","遼源","四平","松原","通化","延邊朝鮮族自治州");
Data_Area_City[14] = new Array("常州","淮安","連雲港","南京","南通","蘇州","宿遷","泰州","無錫","徐州","鹽城","揚州","鎮江");
Data_Area_City[15] = new Array("撫州","贛州","吉安","景德鎮","九江","南昌","萍鄉","上饒","新余","宜春","鷹潭");
Data_Area_City[16] = new Array("鞍山","本溪","朝陽","沈陽","鐵嶺","營口");
Data_Area_City[17] = new Array("阿拉善盟","巴彥淖爾盟","包頭","錫林郭勒盟","興安盟");
Data_Area_City[18] = new Array("固原","石嘴山","吳忠","銀川");
Data_Area_City[19] = new Array("果洛藏族自治州","西寧","玉樹藏族自治州");
Data_Area_City[20] = new Array("濱州","德州","東營","菏澤","濰坊","煙台","棗庄","淄博");
Data_Area_City[21] = new Array("長治","大同","晉城","晉中","臨汾","呂梁","朔州","太原","忻州","陽泉","運城");
Data_Area_City[22] = new Array("安康","寶雞","漢中","商洛","銅川","渭南","西安","咸陽","延安","榆林");
Data_Area_City[23] = new Array("上海");
Data_Area_City[24] = new Array("阿壩藏族羌族自治州","綿陽","南充","內江","攀枝花","遂寧","雅安","宜賓","資陽","自貢","瀘州");
Data_Area_City[25] = new Array("天津");
Data_Area_City[26] = new Array("阿里","昌都","拉薩","林芝","那曲","日喀則","山南");
Data_Area_City[27] = new Array("阿克蘇","和田","喀什","吐魯番","烏魯木齊","五家渠","伊犁哈薩克自治州");
Data_Area_City[28] = new Array("保山","玉溪","昭通");
Data_Area_City[29] = new Array("杭州","湖州","嘉興","金華","麗水","寧波","紹興","台州","溫州","舟山","衢州");
Data_Area_City[30] = new Array("重慶");
//學歷
var Data_School = new Array("初中","高中","中專","大專","本科","雙學位");
//行業
var Data_Instry = new Array("計算機類","金融/證券/保險類","財務類","工業/工廠類 ","技工類","機械/設備維修類","動力電氣類", "輕工類 ","美容保健類");
//時間
var Data_Date = new Array("今天","三天內","一個星期內","半個月內","一個月內","三個月內","半年內","一年內","所有");
//層狀態
var Date_DivState=new Array()
//滑鼠焦點狀態
var focusState=false
var Search = new Object();
//--------------------------------------
// 初始化Div標簽事件
// Joshua 2007-02-07
//--------------------------------------
Search.Init = function(){
document.getElementById("Data_Area").onclick = Search.ShowArea.Init;
document.getElementById("Data_School").onclick = Search.ShowSchool;
document.getElementById("Data_Instry").onclick = Search.ShowInstry;
document.getElementById("Data_Date").onclick = Search.ShowDate;
}
//-------------------------------
// 創建一個Div對象
// Joshua 2007-02-07
//-------------------------------
Search.CreateDiv = function(obj,Id,X,Y,oWidth,oHeight){
var Obj_Div = document.createElement("div");
Obj_Div.setAttribute("id",Id);
Obj_Div.style.position="absolute";
Obj_Div.style.background="#fff";
Obj_Div.style.zIndex = "10000";
Obj_Div.style.border="1px solid #CCCCCC";
Obj_Div.style.padding="3px";
Obj_Div.style.lineHeight ="120%";
Obj_Div.style.left=X+"px";
Obj_Div.style.top=Y+"px";
Obj_Div.style.whiteSpace="nowrap";
Obj_Div.style.width= oWidth + "px";
Obj_Div.style.height= oHeight + "px";
obj.appendChild(Obj_Div);
}
//------------------------------------
// 判斷Div是否存在
// Joshua 2007-02-07
//------------------------------------
Search.IsDiv = function(Id){
var result = true
try{
document.getElementById(Id).a=1;
}catch(e){
result = false
}
return(result);
}
//----------------------------
// 刪除Div對象
// Joshua 2007-02-07
//----------------------------
Search.RemoveDiv = function(Id){
try{
document.getElementById(Id).removeNode(true);
}catch(e){}
}
//---------------------------
// 遍歷清除無用Div對象
// Joshua 2007-02-07
//---------------------------
Search.DelDiv = function(){
try{
document.getElementById("Div_Area").removeNode(true);
document.getElementById("Data_Area").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">4</font>" + document.getElementById("Data_Area").innerText.substring(1,document.getElementById("Data_Area").innerText.length);
}catch(e){}
try{
document.getElementById("Div_School").removeNode(true);
document.getElementById("Data_School").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">4</font>" + document.getElementById("Data_School").innerText.substring(1,document.getElementById("Data_School").innerText.length);
}catch(e){}
try{
document.getElementById("Div_Instry").removeNode(true);
document.getElementById("Data_Instry").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">4</font>" + document.getElementById("Data_Instry").innerText.substring(1,document.getElementById("Data_Instry").innerText.length);
}catch(e){}
try{
document.getElementById("Div_Date").removeNode(true);
document.getElementById("Data_Date").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">4</font>" + document.getElementById("Data_Date").innerText.substring(1,document.getElementById("Data_Date").innerText.length);
}catch(e){}
}
//--------------------------
// 失去焦點,清楚Div對象
// Joshua 2007-02-07
//--------------------------
Search.Lostfocus = function(){
if(!focusState){
try{
document.getElementById("Div_Area").removeNode(true);
document.getElementById("Data_Area").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">4</font>" + document.getElementById("Data_Area").innerText.substring(1,document.getElementById("Data_Area").innerText.length);
}catch(e){}
try{
document.getElementById("Div_School").removeNode(true);
document.getElementById("Data_School").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">4</font>" + document.getElementById("Data_School").innerText.substring(1,document.getElementById("Data_School").innerText.length);
}catch(e){}
try{
document.getElementById("Div_Instry").removeNode(true);
document.getElementById("Data_Instry").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">4</font>" + document.getElementById("Data_Instry").innerText.substring(1,document.getElementById("Data_Instry").innerText.length);
}catch(e){}
try{
document.getElementById("Div_Date").removeNode(true);
document.getElementById("Data_Date").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">4</font>" + document.getElementById("Data_Date").innerText.substring(1,document.getElementById("Data_Date").innerText.length);
}catch(e){}
}
}
Search.ShowArea = function(){} //空對象
//------------------------
// 顯示地區一級菜單
// Joshua 2007-02-07
//------------------------
Search.ShowArea.Init = function(){
focusState = true;
Search.DelDiv()//刪除其他DIV標簽
if(!Search.IsDiv("Div_Area")){//判斷對象是否建立,防止再次激發事件,引起的對象多次重復建立
//更改Data_Area對象內容
document.getElementById("Data_Area").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">6</font>" + document.getElementById("Data_Area").innerText.substring(1,document.getElementById("Data_Area").innerText.length);
//顯示層
Search.CreateDiv(document.body,"Div_Area",Search.getSelectPosition(document.getElementById("Data_Area"))[0],Search.getSelectPosition(document.getElementById("Data_Area"))[1]+12,80,0);
//創建省級分類
for(var i=0;i<Data_Area_Province.length;i++){
var Obj_Span = document.createElement("div");
Obj_Span.setAttribute("id","Div_Area_Province_"+i);
Obj_Span.setAttribute("value",i);
Obj_Span.style.cursor="pointer";
Obj_Span.onmouseover = function(){
focusState = true;
this.style.border="1px solid #827C5F";
this.style.background="#CEC497";
}
Obj_Span.onmouseout = function(){
focusState = false;
if (!Date_DivState[this.getAttribute("value")]){
this.style.border="0px solid #ffffff";
this.style.background="#fff";}
}
Obj_Span.onclick = function(){
focusState = true;
//恢復非本對象的其他一級菜單項目樣式
for(var i=0;i<Date_DivState.length;i++){
if(Date_DivState[i]==true&&this.value!=document.getElementById("Div_Area_Province_"+i).value){
document.getElementById("Div_Area_Province_"+i).style.border="0px solid #ffffff";
document.getElementById("Div_Area_Province_"+i).style.background="#fff";
}
}
//設置層狀態
Date_DivState[this.getAttribute("value")] = true;
//生成二級菜單
Search.ShowArea.InitCity(this.getAttribute("value"),this)
}
Obj_Span.innerHTML = Data_Area_Province[i] + "<font face=\"webdings\" style=\"font-size:10px; color:#000;position:absolute;right:3px; \">4</font>";
document.getElementById("Div_Area").appendChild(Obj_Span);
}
}
}
//----------------------
// 顯示地區二級菜單
// Joshua 2007-02-07
//----------------------
Search.ShowArea.InitCity = function(oId,obj){
if(!Search.IsDiv("Div_Area_City_"+oId)){//判斷對象是否建立,防止再次激發事件,引起的對象多次重復建立
//刪除除對象外存在的二級菜單對象
for(var i=0;i<Date_DivState.length;i++){
if(Date_DivState[i]==true&&i!=oId){
Search.RemoveDiv("Div_Area_City_"+i);
Date_DivState[i]=null;
}
}
//生成指定的二級菜單對象
Search.CreateDiv(obj,"Div_Area_City_"+oId,obj.offsetWidth,obj.offsetTop,50,0);

if(oId<Data_Area_Province.length){
for(var i=0;i<Data_Area_City[oId].length;i++){
var Obj_Span = document.createElement("div");
Obj_Span.setAttribute("id","Div_Area_City"+i);
Obj_Span.style.cursor="pointer";
Obj_Span.innerText = Data_Area_City[oId][i];
Obj_Span.setAttribute("value",oId);
Obj_Span.onmouseover = function(){
focusState = true;
this.style.border="1px solid #827C5F";
this.style.background="#CEC497";
}
Obj_Span.onmouseout = function(){
focusState = false;
this.style.border="0px solid #ffffff";
this.style.background="#fff";
}
Obj_Span.onclick = function(){
//設置Data_Area的對象為選擇的職
document.getElementById("Data_Area").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">4</font>" + this.innerText;
//刪除Div對象
Search.RemoveDiv("Div_Area");
//恢復狀態數組
Date_DivState.length=0;
}
document.getElementById("Div_Area_City_"+oId).appendChild(Obj_Span);
}
}
}

}
//-------------------
// 學歷Div操作
// Joshua 2007-02-07
//-------------------
Search.ShowSchool=function(){
focusState = true;
Search.DelDiv();//刪除其他DIV標簽
if(!Search.IsDiv("Div_School")){//判斷對象是否建立,防止再次激發事件,引起的對象多次重復建立
document.getElementById("Data_School").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">6</font>" + document.getElementById("Data_School").innerText.substring(1,document.getElementById("Data_School").innerText.length);
Search.CreateDiv(document.body,"Div_School",Search.getSelectPosition(document.getElementById("Data_School"))[0],Search.getSelectPosition(document.getElementById("Data_School"))[1]+12,60,0);
for(var i=0;i<Data_School.length;i++){
var Obj_Span = document.createElement("div");
Obj_Span.setAttribute("id","Div_School_"+i);
Obj_Span.setAttribute("value",i);
Obj_Span.style.cursor="pointer";
Obj_Span.onmouseover = function(){
focusState = true;
this.style.border="1px solid #827C5F";
this.style.background="#CEC497";
}
Obj_Span.onmouseout = function(){
focusState = false;
this.style.border="0px solid #ffffff";
this.style.background="#fff";
}
Obj_Span.onclick = function(){
document.getElementById("Data_School").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">4</font>" + this.innerText;
Search.RemoveDiv("Div_School");
}
Obj_Span.innerHTML = Data_School[i];
document.getElementById("Div_School").appendChild(Obj_Span);
}
}
}
//----------------------
// 行業Div操作
// Joshua 2007-02-07
//----------------------
Search.ShowInstry = function(){
focusState = true;
Search.DelDiv();//刪除其他DIV標簽
if(!Search.IsDiv("Div_Instry")){//判斷對象是否建立,防止再次激發事件,引起的對象多次重復建立
document.getElementById("Data_Instry").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">6</font>" + document.getElementById("Data_Instry").innerText.substring(1,document.getElementById("Data_Instry").innerText.length);
Search.CreateDiv(document.body,"Div_Instry",Search.getSelectPosition(document.getElementById("Data_Instry"))[0],Search.getSelectPosition(document.getElementById("Data_Instry"))[1]+12,160,0);
for(var i=0;i<Data_Instry.length;i++){
var Obj_Span = document.createElement("div");
Obj_Span.setAttribute("id","Div_Instry_"+i);
Obj_Span.setAttribute("value",i);
Obj_Span.style.cursor="pointer";
Obj_Span.onmouseover = function(){
focusState = true;
this.style.border="1px solid #827C5F";
this.style.background="#CEC497";
}
Obj_Span.onmouseout = function(){
focusState = false;
this.style.border="0px solid #ffffff";
this.style.background="#fff";
}
Obj_Span.onclick = function(){
document.getElementById("Data_Instry").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">4</font>" + this.innerText;
Search.RemoveDiv("Div_Instry");
}
Obj_Span.innerHTML = Data_Instry[i];
document.getElementById("Div_Instry").appendChild(Obj_Span);
}
}
}
//-----------------------------
// 時間Div操作
// Joshua 2007-02-07
//-----------------------------
Search.ShowDate = function(){
focusState = true;
Search.DelDiv();//刪除其他DIV標簽
if(!Search.IsDiv("Div_Date")){//判斷對象是否建立,防止再次激發事件,引起的對象多次重復建立
document.getElementById("Data_Date").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">6</font>" + document.getElementById("Data_Date").innerText.substring(1,document.getElementById("Data_Date").innerText.length);
Search.CreateDiv(document.body,"Div_Date",Search.getSelectPosition(document.getElementById("Data_Date"))[0],Search.getSelectPosition(document.getElementById("Data_Date"))[1]+12,60,0);
for(var i=0;i<Data_Date.length;i++){
var Obj_Span = document.createElement("div");
Obj_Span.setAttribute("id","Div_Date_"+i);
Obj_Span.setAttribute("value",i);
Obj_Span.style.cursor="pointer";
Obj_Span.onmouseover = function(){
focusState = true;
this.style.border="1px solid #827C5F";
this.style.background="#CEC497";
}
Obj_Span.onmouseout = function(){
focusState = false;
this.style.border="0px solid #ffffff";
this.style.background="#fff";
}
Obj_Span.onclick = function(){
document.getElementById("Data_Date").innerHTML = "<font face=\"webdings\" style=\"font-size:10px; color:#ff9900;\">4</font>" + this.innerText;
Search.RemoveDiv("Div_Date");
}
Obj_Span.innerHTML = Data_Date[i];
document.getElementById("Div_Date").appendChild(Obj_Span);
}
}
}
//-----------------------
// 獲取一個對象的坐標
//------------------------
Search.getSelectPosition = function(Gobj) {
var objLeft = Gobj.offsetLeft;
var objTop = Gobj.offsetTop;
var objParent = Gobj.offsetParent;
while (objParent!= null) {
objLeft += objParent.offsetLeft;
objTop += objParent.offsetTop;
objParent = objParent.offsetParent;
}
return([objLeft,objTop]);
}
//------------------------
// 頁面初始化
//------------------------
window.onload=function(){
Search.Init();
}
window.document.onclick=function (){
Search.Lostfocus();
}
</script>
<style>
BODY{FONT-SIZE: 12px;}
</style>
</head>
<body>
<span id="Data_Area" style="cursor:pointer;"><font face="webdings" style="font-size:10px; color:#ff9900;">4</font>地區</span>
<span id="Data_School" style="cursor:pointer;"><font face="webdings\" style="font-size:10px; color:#ff9900;">4</font>學歷</span>
<span id="Data_Instry" style="cursor:pointer;"><font face="webdings" style="font-size:10px; color:#ff9900;">4</font>行業</span>
<span id="Data_Date" style="cursor:pointer;"><font face="webdings" style="font-size:10px; color:#ff9900;">4</font>時間</span>
</body>
</html>

㈤ 麻煩詳細解釋一下下面 web下拉菜單 的代碼什麼意思

asp製作很HTM製作是一樣的。
只是看你有沒有用到動態輸出鏈接及標題了。

㈥ 下拉菜單的在web頁面的應用

以條形菜單欄和菜單欄中每個菜單項的彈出菜單窗口兩部分組成,一般作為應用系統的主菜單使用。

㈦ web頁面下拉菜單

js的,我有很多,怎麼給你哦?

㈧ 關於web中下拉列表的幾種實現方法

<!-- 下拉列表框 -->
<div>
<select name="selectAge" id="selectAge">
<option value="1">18-21</option>
<option value="2">22-25</option>
<option value="3">26-29</option>
<option value="4">30-35</option>
<option value="5">Over35</option>
</select>
</div>

<!-- 下拉選擇框(多加了multiple="multiple") -->
<div>
<select name="selectAge" id="selectAge" multiple="multiple">
<option value="1">18-21</option>
<option value="2">22-25</option>
<option value="3">26-29</option>
<option value="4">30-35</option>
<option value="5">Over35</option>
</select>
</div>
上面的兩種是用HTML標簽實現的

還有一些實現方法是通過struts方法中的標簽實現的(不是很常用)

㈨ java web如何 初始化下拉列表

一般不要初始化,即使載入了,如果沒有被使用,浪費流量。給 select 添加 onselect 事件,使用Ajax 調用資料庫,一般請求過一次後會緩存到本機,很方便的。試試吧

㈩ 在java web中下拉列表框標記中〈option〉是什麼意思

這個是用來設置枚舉值,也就是下拉框裡面的參數,option裡面有value屬性,表示你選中後獲取的數據