Javascript²Ù×÷select¿Ø¼þ´óÈ«
1ÅжÏselectÑ¡ÏîÖÐ ÊÇ·ñ´æÔÚValue="paraValue"µÄItem
2ÏòselectÑ¡ÏîÖÐ ¼ÓÈëÒ»¸öItem
3´ÓselectÑ¡ÏîÖРɾ³ýÒ»¸öItem
4ɾ³ýselectÖÐÑ¡ÖеÄÏî
5ÐÞ¸ÄselectÑ¡ÏîÖÐ value="paraValue"µÄtextΪ"paraText"
6ÉèÖÃselectÖÐtext="paraText"µÄµÚÒ»¸öItemΪѡÖÐ
7ÉèÖÃselectÖÐvalue="paraValue"µÄItemΪѡÖÐ
8µÃµ½selectµÄµ±Ç°Ñ¡ÖÐÏîµÄvalue
9µÃµ½selectµÄµ±Ç°Ñ¡ÖÐÏîµÄtext
10µÃµ½selectµÄµ±Ç°Ñ¡ÖÐÏîµÄIndex
11Çå¿ÕselectµÄÏî
// 1.ÅжÏselectÑ¡ÏîÖÐ ÊÇ·ñ´æÔÚValue="paraValue"µÄItem
function jsSelectIsExitItem(objSelect, objItemValue) {
var isExit = false;
for (var i = 0; i < objSelect.options.length; i++) {
if (objSelect.options[i].value == objItemValue) {
isExit = true;
break;
}
}
return isExit;
}
// 2.ÏòselectÑ¡ÏîÖÐ ¼ÓÈëÒ»¸öItem
function jsAddItemToSelect(objSelect, objItemText, objItemValue) {
//ÅжÏÊÇ·ñ´æÔÚ
if (jsSelectIsExitItem(objSelect, objItemValue)) {
alert("¸ÃItemµÄValueÖµÒѾ´æÔÚ");
} else {
var varItem = new Option(objItemText, objItemValue);
objSelect.options.add(varItem);
alert("³É¹¦¼ÓÈë");
}
}
// 3.´ÓselectÑ¡ÏîÖРɾ³ýÒ»¸öItem
function jsRemoveItemfromSelect(objSelect, objItemValue) {
//ÅжÏÊÇ·ñ´æÔÚ
if (jsSelectIsExitItem(objSelect, objItemValue)) {
for (var i = 0; i < objSelect.options.length; i++) {
if (objSelect.options[i].value == objItemValue) {
objSelect.options.remove(i);
break;
}
}
alert("³É¹¦É¾³ý");
} else {
alert("¸ÃselectÖÐ ²»´æÔÚ¸
Ïà¹ØÎĵµ£º
JavaScript ×Ö·û´®×ª»»Êý×Ö(תÔØ)
·½·¨Ö÷ÒªÓÐÈýÖÖ
ת»»º¯Êý¡¢Ç¿ÖÆÀàÐÍת»»¡¢ÀûÓÃjs±äÁ¿ÈõÀàÐÍת»»¡£
1. ת»»º¯Êý
jsÌṩÁËparseInt()ºÍparseFloat()Á½¸öת»»º¯Êý¡£Ç°Õß°Ñֵת»»³ÉÕûÊý£¬ºóÕß°Ñֵת»»³É¸¡µãÊý¡£Ö»ÓжÔStringÀàÐ͵÷ÓÃÕâЩ·½·¨£¬ÕâÁ½¸öº¯Êý²ÅÄÜÕýÈ·ÔËÐУ»¶ÔÆäËûÀàÐÍ·µ»ØµÄ¶¼ÊÇNaN(Not a Number)¡£
ÔÚÅ ......
¹ØÓÚThis
1. ËüÊÇÒ»¸ö¹Ø¼ü×Ö£¬²¢²»ÊDZäÁ¿Ãû»òÊôÐÔÃû¡£
2. Ëüʵ¼ÊÖ¸functionËù¹ØÁªµÄ¶ÔÏó£¬Èç¹ûfunctionûÓйØÁªÈκζÔÏó£¬ÔòthisÊÇGlobal¶ÔÏó
var msg = 'I am global';
function showMsg(){
alert(this.msg);
};
function nestedShowMsg (){
var nested = function(){
alert(this.msg);
};
nested();
......
//¶¨ÒåÒª´ò¿ªµÄ¶Ô»°¿òÒ³ÃæµÄµØÖ· Ò»°ãÓÃactionÌøתҪдÃ÷actionµÄµØÖ·£¬Èç¹ûÐèÒª²ÎÊý£¬ÔòÔÚºóÃæÆ´½Ó
var urlDialog = "grpBlackWhiteManageAction.do?act=choiceMessageModel&GrpBWhiteListLevel=0";
//¶¨ÒåÒªµ¯³öµÄ¶Ô»°¿òµÄģʽ£¬dialogWidth¿í£¬dialogHeight¸ß µÈµÈ
var style = "dialogWidth=600px;dialogH ......
1. ±ê×¼µÄ·½·¨
<mce:script type="text/javascript"><!--
function openWin(src, width, height, showScroll){
window.showModalDialog (src,"","location:No;status:No;help:No;dialogWidth:"+width+";dialogHeight:"+height+";scroll:"+showScroll+";");
}
// --></mce:script> &n ......
ÖÆ×÷ÍøÒ³µÄ¹ý³ÌÖУ¬ÄãÓÐʱºòÐèÒªÖªµÀij¸öÔªËØÔÚÍøÒ³ÉϵÄÈ·ÇÐλÖá£
ÏÂÃæµÄ½Ì³Ì×ܽáÁËJavascriptÔÚÍøÒ³¶¨Î»·½ÃæµÄÏà¹Ø֪ʶ¡£
Ò»¡¢ÍøÒ³µÄ¾ø¶Ô´óСºÍÏà¶Ô´óС
Ê×ÏÈ£¬ÒªÃ÷È·Á½¸ö»ù±¾¸ÅÄî¡£
Ò»ÕÅÍøÒ³µÄÈ«²¿Ãæ»ý£¬¾ÍÊÇËüµÄ¾ø¶Ô´óС¡£Í¨³£Çé¿öÏ£¬ÍøÒ³µÄ¾ø¶Ô´óСÓÉÄÚÈݺÍCSSÑùʽ±í¾ö¶¨¡£
ÍøÒ³µÄÏà¶Ô´óСÔòÊÇÖ¸ÔÚä¯ÀÀÆ÷´°¿ÚÖп ......