javascriptÖ®HTML£¨select option£©Ïê½â
Ò»¡¢»ù´¡Àí½â:
var e = document.getElementById("selectId");
e. options= new Option("Îı¾","Öµ") ;
//´´½¨Ò»¸öoption¶ÔÏó,¼´ÔÚ<select>±êÇ©Öд´½¨Ò»¸ö»ò¶à¸ö<option value="Öµ">Îı¾</option>
//optionsÊǸöÊý×é,ÀïÃæ¿ÉÒÔ´æ·Å¶à¸ö<option value="Öµ">Îı¾</option>ÕâÑùµÄ±êÇ©
1:options[ ]Êý×éµÄÊôÐÔ:
lengthÊôÐÔ---------³¤¶ÈÊôÐÔ
selectedIndexÊôÐÔ--------µ±Ç°±»Ñ¡ÖеĿòÖеÄÎı¾µÄË÷ÒýÖµ,´ËË÷ÒýÖµÊÇÄÚ´æ×Ô¶¯·ÖÅäµÄ(0,1,2,3.....)¶ÔÓ¦(µÚÒ»¸öÎı¾Öµ,µÚ¶þ¸öÎı¾Öµ,µÚÈý¸öÎı¾Öµ,µÚËĸöÎı¾Öµ..........)
2:µ¥¸öoptionµÄÊôÐÔ(---obj.options[obj.selecedIndex]ÊÇÖ¸¶¨µÄij¸ö<option>±êÇ©,ÊÇÒ»¸ö---)
textÊôÐÔ---------·µ»Ø/Ö¸¶¨ Îı¾
valueÊôÐÔ------·µ»Ø/Ö¸¶¨ Öµ£¬Óë<options value="...">Ò»Ö¡£
indexÊôÐÔ-------·µ»Øϱê,
selected ÊôÐÔ-------·µ»Ø/Ö¸¶¨¸Ã¶ÔÏóÊÇ·ñ±»Ñ¡ÖÐ.ͨ¹ýÖ¸¶¨ true »òÕß false£¬¿ÉÒÔ¶¯Ì¬µÄ¸Ä±äÑ¡ÖÐÏî
defaultSelected ÊôÐÔ-----·µ»Ø¸Ã¶ÔÏóĬÈÏÊÇ·ñ±»Ñ¡ÖС£true / false¡£
3:optionµÄ·½·¨
Ôö¼ÓÒ»¸ö<option>±êÇ©-----obj.options.add(new("Îı¾","Öµ"));<Ôö>
ɾ³ýÒ»¸ö<option>±êÇ©-----obj.options.remove(obj.selectedIndex)<ɾ>
»ñµÃÒ»¸ö<option>±êÇ©µÄÎı¾-----obj.options[obj.selectedIndex].text<²é>
ÐÞ¸ÄÒ»¸ö<option>±êÇ©µÄÖµ-----obj.options[obj.selectedIndex]=new Option("ÐÂÎı¾","ÐÂÖµ")<¸Ä>
ɾ³ýËùÓÐ<option>±êÇ©-----obj.options.length = 0
»ñµÃÒ»¸ö<option>±êÇ©µÄÖµ-----obj.options[obj.selectedIndex].value
×¢Òâ:
a:ÉÏÃæµÄдµÄÊÇÈçÕâÑùÀàÐ͵ķ½·¨obj.options.function()¶ø²»Ð´obj.funciton,ÊÇÒòΪΪÁË¿¼ÂÇÔÚIEºÍFF ϵļæÈÝ,Èçobj.add()Ö»ÄÜÔÚIEÖÐÓÐЧ.
b:obj.optionÖеÄoption²»ÐèÒª´óд,new OptionÖеÄOptionÐèÒª´óд
¶þ ¡¢Ó¦ÓÃ
<html>
<head>
<script language="javascript">
function number(){
var obj = document.getElementById("mySelect");
//obj.options[obj.selectedIndex] = new Option("ÎҵijԳÔ","4");//ÔÚµ±Ç°Ñ¡ÖеÄÄǸöµÄÖµÖиıä
//obj.options.add(new Option("ÎҵijԳÔ","4"));ÔÙÌí¼ÓÒ»¸öoption
//alert(obj.selectedIndex);//ÏÔʾÐòºÅ£¬option×Ô¼ºÉèÖõÄ
//obj.options[obj.selectedIndex].text = "ÎҵijԳÔ";¸ü¸ÄÖµ
Ïà¹ØÎĵµ£º
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ºáÏò²»¼ä¶Ï¹ö¶¯Í¼Æ¬</title>
<meta http- ......
ÀûÓÃ Page.RegisterStartupScript("", "<script language='javascript'> results();</script>");
»òÕßÊÇ Page.RegisterClient ......
<p>: ¸ñʽ»¯¶ÎÂä; <h1>,<h6> ±êÌâ; <blockquote>-- ÒýÓõÄÎı¾; <pre>--Ô¤Ïȸñʽ»¯ºÃµÄÎı¾;±£ÁôÔÓеĸñʽ.
<ol><dl><ul>:˳ÐòÁÐ±í£¬¶¨ÒåÁбí,ÎÞ±êºÅÁбí. <li>ÓÃÒÔÏÔʾµ¥¸öµÄÔªËØ; <dl><dt><dd></dd></dt><dl>
< ......
ÔÚÐÂÔöÊý¾ÝÏîµÄʱºò£¬ÓÃajaxʵÏÖÎÞË¢ÐÂÌá½»£¬µ«ÉÏ´«ÎļþµÄʱºò£¬ÓÉÓÚÊý¾ÝÀàÐÍÔÒò£¬²»Äܽ«Ò³ÃæµÄ<asp:FileUpload>ÖÐÒÔ×Ö·û´®ÖµµÄ·½Ê½´«µ½jsÀïµ÷Óá£ÎÒÒ»¹²ÕÒµ½ÁËÁ½¸ö·½·¨ÓèÒÔ½â¾ö£¬ÊµÏÖÎÞË¢ÐÂÉÏ´«¡£
µÚÒ»ÖÖ·½·¨£ºÀûÓÃjsµÄADODB.Stream£¬½«ÎļþÏÈת»»³ÉÁ÷£¬ÔÙͨ¹ýjsÉÏ´«µ½·þÎñÆ÷£¬ÕâÑùÓиöºÃ´¦¾ÍÊÇ¿ÉÒÔÉÏ´«³¬´óÎļþ£ ......
1.document.formName.item("itemName") ÎÊÌâ
˵Ã÷:IEÏÂ,¿ÉÒÔʹÓÃdocument.formName.item("itemName")»òdocument.formName.elements["elementName"];FirefoxÏÂ,Ö»ÄÜʹÓÃdocument.formName.elements["elementName"].
½â¾ö·½·¨:ͳһʹÓÃdocument.formName.elements["elementName"].
2.¼¯ºÏÀà¶ÔÏóÎÊÌâ
˵Ã÷:IEÏÂ,¿ÉÒÔʹÓÃ() ......