📄 optiongrp.asp
字号:
<SCRIPT RUNAT=SERVER LANGUAGE="JavaScript">
// ************************************************************************
// Microsoft Script Library
// Visual InterDev 6.0 OptionGroup Object for ASP
//
// Copyright 1998 Microsoft Corporation. All Rights Reserved.
// ************************************************************************
function CreateOptionGroup(strName,funcInit,objParent)
{
if (typeof(strName) == 'string' && strName != '')
{
var objOptionGroup = new _OptionGroup(strName);
eval(strName + " = objOptionGroup;");
objOptionGroup._funcInit = funcInit;
thisPage.advise(PAGE_ONINIT,strName + '._restoreState()');
return objOptionGroup;
}
@if (@trace_warnings)
thisPage._traceWarning('Err 428: Invalid argument [strName]. Must provide a valid string.','optiongrp.asp','CreateOptionGroup(strName)');
@end
return null;
}
function _OptionGroup(strName)
{
if (typeof(_bOPTPrototypeCalled) == 'undefined')
_OPT__Prototype();
// public members
this.id = strName;
this.name = strName;
// private members
this._options = new Array();
this._objEventManager = CreateEventManager();
this._objEventManager.adviseDefaultHandler(this.name,OPT_ONCHANGE);
}
function _OPT__Prototype()
{
_bOPTPrototypeCalled = 1;
//events
OPT_ONCHANGE = 'onchange';
// public members
_OptionGroup.prototype.maintainState = true;
// private members
_OptionGroup.prototype._bVisible = true;
_OptionGroup.prototype._nBorder = 0;
_OptionGroup.prototype._nAlignment = 0;
_OptionGroup.prototype._selectedIndex = 0;
_OptionGroup.prototype._objDataSource = null;
_OptionGroup.prototype._strDataField = '';
//public methods
_OptionGroup.prototype.isVisible = _OPT_isVisible;
_OptionGroup.prototype.show = _OPT_show;
_OptionGroup.prototype.hide = _OPT_hide;
_OptionGroup.prototype.getBorder = _OPT_getBorder;
_OptionGroup.prototype.setBorder = _OPT_setBorder;
_OptionGroup.prototype.getAlignment = _OPT_getAlignment;
_OptionGroup.prototype.setAlignment = _OPT_setAlignment;
_OptionGroup.prototype.getButton = _OPT_getButton;
_OptionGroup.prototype.addItem = _OPT_addItem;
_OptionGroup.prototype.removeItem = _OPT_removeItem;
_OptionGroup.prototype.clear = _OPT_clear;
_OptionGroup.prototype.getCount = _OPT_getCount;
_OptionGroup.prototype.getValue = _OPT_getValue;
_OptionGroup.prototype.setValue = _OPT_setValue;
_OptionGroup.prototype.getCaption = _OPT_getCaption;
_OptionGroup.prototype.setCaption = _OPT_setCaption;
_OptionGroup.prototype.selectByValue = _OPT_selectByValue;
_OptionGroup.prototype.selectByCaption = _OPT_selectByCaption;
_OptionGroup.prototype.selectByIndex = _OPT_selectByIndex;
_OptionGroup.prototype.getSelectedIndex = _OPT_getSelectedIndex;
_OptionGroup.prototype.getRowSource = _OPT_getRowSource
_OptionGroup.prototype.setRowSource = _OPT_setRowSource
_OptionGroup.prototype.getDataSource = _SOM_getDataSource;
_OptionGroup.prototype.setDataSource = _SOM_setDataSource;
_OptionGroup.prototype.getDataField = _SOM_getDataField;
_OptionGroup.prototype.setDataField = _SOM_setDataField;
_OptionGroup.prototype.advise = _OPT_advise;
_OptionGroup.prototype.unadvise = _OPT_unadvise;
_OptionGroup.prototype.display = _OPT_display;
//private methods
_OptionGroup.prototype._fireEvent = _EM__fireEvent;
_OptionGroup.prototype._preserveState = _OPT__preserveState;
_OptionGroup.prototype._restoreState = _OPT__restoreState;
_OptionGroup.prototype._hasState = _OPT__hasState;
_OptionGroup.prototype._onrowenter = _OPT__onrowenter;
_OptionGroup.prototype._onbeforeupdate = _OPT__onbeforeupdate;
//scope implementation in _OPT__Prototype function
function _OPT__Option()
{
this.text = '';
this.value = '';
this.disabled = false;
}
function _OPT_isVisible()
{ return this._bVisible; }
function _OPT_show()
{ this._bVisible = true; }
function _OPT_hide()
{ this._bVisible = false; }
function _OPT_getBorder()
{ return this._nBorder; }
function _OPT_setBorder(nBorder)
{ this._nBorder = nBorder; }
function _OPT_getAlignment()
{ return this._nAlignment; }
function _OPT_setAlignment(nAlignment)
{
if (typeof(nAlignment) != 'undefined')
{
if (nAlignment == '0')
this._nAlignment = 0;
else
this._nAlignment = 1;
return true;
}
@if (@trace_warnings)
thisPage._traceWarning('Err 402: Argument [nAlignment] is undefined.','optiongrp.asp',this.name + '.setAlignment(nAlignment)');
@end
return false;
}
function _OPT_getButton(nIndex)
{
if (!isNaN(parseInt(nIndex)) && nIndex >= 0 && nIndex < this.getCount())
return this._options[Number(nIndex)];
@if (@trace_warnings)
thisPage._traceWarning('Err 431: Invalid argument or argument out of bounds. [nIndex = ' + nIndex + ']','optiongrp.asp',this.name + '.getButton(nIndex)');
@end
}
function _OPT_addItem(strText,value,nIndex)
{
@if (@trace_warnings)
if (typeof(strText) != 'string')
thisPage._traceWarning('Err 443: Wrong argument type [strText]. Expect a string.','optiongrp.asp',this.name + '.addItem(strText,[value],[nIndex])');
@end
var nCount = this.getCount();
if (typeof(nIndex) == 'undefined')
nIndex = nCount;
if (typeof(value) == 'undefined')
value = strText;
if (!isNaN(parseInt(nIndex)))
{ // add item at given nIndex
var opt = new _OPT__Option;
opt.text = String(strText);
opt.value = value;
if (nIndex < 0) // add as first item in list
nIndex = 0;
if (nIndex < nCount)
{ // insert item at given index
var aTemp = this._options.slice(nIndex);
this._options.length = nIndex;
this._options[Number(nIndex)] = opt;
this._options = this._options.concat(aTemp);
return nIndex;
}
else
{ // add item to end of list
this._options[nCount] = opt;
return nCount;
}
}
@if (@trace_warnings)
thisPage._traceWarning('Err 440: Wrong argument type [nIndex = ' + nIndex + ']. Expect a number.','optiongrp.asp',this.name + '.addItem(strText,[value],[nIndex])');
@end
return -1; // failed to add item
}
function _OPT_removeItem(nIndex)
{
if (typeof(nIndex) == 'undefined')
nIndex = this._selectedIndex;
if (!isNaN(parseInt(nIndex)) && nIndex >= 0 && nIndex < this.getCount())
{ // remove item at nIndex
var aTemp = this._options.slice(Number(nIndex)+1);
this._options.length = nIndex;
this._options = this._options.concat(aTemp);
return true;
}
@if (@trace_warnings)
thisPage._traceWarning('Err 431: Invalid argument or argument out of bounds. [nIndex = ' + nIndex + ']','optiongrp.asp',this.name + '.removeItem([nIndex])');
@end
return false;
}
function _OPT_clear()
{ this._options.length = 0; }
function _OPT_getCount()
{ return this._options.length; }
function _OPT_getValue(nIndex)
{
if (typeof(nIndex) == 'undefined')
nIndex = this._selectedIndex;
if (!isNaN(parseInt(nIndex)) && nIndex >= 0 && nIndex < this.getCount())
return this._options[nIndex].value;
@if (@trace_warnings)
thisPage._traceWarning('Err 431: Invalid argument or argument out of bounds. [nIndex = ' + nIndex + ']','optiongrp.asp',this.name + '.getValue([nIndex])');
@end
return '';
}
function _OPT_setValue(value, nIndex)
{
@if (@trace_warnings)
if (typeof(value) == 'undefined')
thisPage._traceWarning('Err 403: Argument [value] is undefined.','optiongrp.asp',this.name + '.setValue(value,[nIndex])');
@end
if (typeof(nIndex) == 'undefined')
nIndex = this._selectedIndex;
if (!isNaN(parseInt(nIndex)) && nIndex >= 0 && nIndex < this.getCount())
{
this._options[nIndex].value = value;
return true;
}
@if (@trace_warnings)
thisPage._traceWarning('Err 431: Invalid argument or argument out of bounds. [nIndex = ' + nIndex + ']','optiongrp.asp',this.name + '.setValue(value,[nIndex])');
@end
return false;
}
function _OPT_getCaption(nIndex)
{
if (typeof(nIndex) == 'undefined')
nIndex = this._selectedIndex;
if (!isNaN(parseInt(nIndex)) && nIndex >= 0 && nIndex < this.getCount())
return this._options[nIndex].text;
@if (@trace_warnings)
thisPage._traceWarning('Err 431: Invalid argument or argument out of bounds. [nIndex = ' + nIndex + ']','optiongrp.asp',this.name + '.getCaption([nIndex])');
@end
return '';
}
function _OPT_setCaption(strCaption,nIndex)
{
@if (@trace_warnings)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -