⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 optiongrp.asp

📁 网上商城的设计与实现
💻 ASP
📖 第 1 页 / 共 2 页
字号:
			if (typeof(strCaption) != 'string')
				thisPage._traceWarning('Err 441: Wrong argument type [strCaption]. Expect a string.','optiongrp.asp',this.name + '.setCaption(strCaption,[nIndex])');
		@end
		if (typeof(nIndex) == 'undefined')
			nIndex = this._selectedIndex;
		if (!isNaN(parseInt(nIndex)) && nIndex >= 0 && nIndex < this.getCount())
		{
			this._options[nIndex].text = String(strCaption);
			return true;
		}
		@if (@trace_warnings)
			thisPage._traceWarning('Err 431: Invalid argument or argument out of bounds. [nIndex = ' + nIndex + ']','optiongrp.asp',this.name + '.setCaption(strCaption,[nIndex])');
		@end
		return false;
	}

	function _OPT_selectByValue(value)
	{	// check for match in _options array
		@if (@trace_warnings)
			if (typeof(value) == 'undefined')
				thisPage._traceWarning('Err 403: Argument [value] is undefined.','optiongrp.asp',this.name + '.selectByValue(value)');
		@end
		for (var i=0; i < this._options.length; i++)
		{
			if (value == this._options[i].value)
			{
				this._selectedIndex = i;
				return i;
			}
		}
		return -1;
	}

	function _OPT_selectByCaption(strCaption)
	{	// check for match in _options array
		@if (@trace_warnings)
			if (typeof(strCaption) != 'string')
				thisPage._traceWarning('Err 441: Wrong argument type [strCaption]. Expect a string.','optiongrp.asp',this.name + '.selectByCaption(strCaption)');
		@end
		for (var i=0; i < this._options.length; i++)
		{
			if (String(strCaption) == this._options[i].text)
			{
				this._selectedIndex = i;
				return i;
			}
		}
		return -1;
	}

	function _OPT_selectByIndex(nIndex)
	{
		if (!isNaN(parseInt(nIndex)) && nIndex >= 0 && nIndex < this.getCount())
		{
			this._selectedIndex = nIndex;
			return nIndex;
		}
		@if (@trace_warnings)
			thisPage._traceWarning('Err 431: Invalid argument or argument out of bounds. [nIndex = ' + nIndex + ']','optiongrp.asp',this.name + '.selectByIndex(nIndex)');
		@end
		return -1;
	}

	function _OPT_getSelectedIndex()
	{	return this._selectedIndex;		}

	function _OPT_getRowSource()
	{	return this._objRowSource;		}

	function _OPT_setRowSource(objRecordset,listField,boundField)
	{	
		if (typeof(objRecordset) == 'object' && this.getCount() == 0)
		{	
			@if (@trace_events)
				thisPage._trace_on = false;
			@end
			var nPos = objRecordset.absolutePosition;
			objRecordset.moveFirst();
			while (!objRecordset.EOF)
			{
				objFields = objRecordset.fields;
				this.addItem(objFields.getValue(listField),objFields.getValue(boundField));
				objRecordset.moveNext();
			}
			objRecordset.moveAbsolute(nPos);
			@if (@trace_events)
				thisPage._trace_on = true;
			@end
			return true;
		}	
		@if (@trace_warnings)
			if (typeof(objRecordset) != 'object')
				thisPage._traceWarning('Err 426: Invalid argument [objRecordset].  Must provide a valid object or null.','optiongrp.asp',this.name + '.setRowSource(objRecordset,listField,boundField)');
		@end
		return false;
	}

	function _OPT_advise(strEvent,funcToCall)
	{	return this._objEventManager.advise(strEvent,funcToCall);	}

	function _OPT_unadvise(strEvent,nAdviseID)
	{	return this._objEventManager.unadvise(strEvent,nAdviseID);	}

	function _OPT_display(bReturnText)
	{
		var strHTML = '';
		if (this._bVisible)
		{
			strHTML = '<' + 'TABLE border=' + this._nBorder + ' cellpadding=0 cellspacing=0><TR><TD>\n';
			strHTML += '<' + 'TABLE id="' + this.id + '" name="' + this.name + '" border=0 cellpadding=2 cellspacing=2>\n';

			if (this._nAlignment != '0')
				strHTML += '<TR>';

			for (var i = 0; i < this._options.length; i++)
			{
				if (this._nAlignment == '0')
					strHTML += '<TR>';
				strHTML += '<TD>';
				
				if (this._options[i].disabled && !thisPage.isDHTMLBrowser())
				{	// mimic disabled for non-DHTML browsers
					strHTML += '<FONT face=arial size=2>(';
					if (this._selectedIndex == i)
						strHTML += '<FONT face=arial size=3><b>o</b></FONT>';
					else
						strHTML += '&nbsp;&nbsp;';
					strHTML += ') </FONT>' + this._options[i].text + '&nbsp;&nbsp;\n';
				}
				else
				{		
					strHTML += '<' + 'INPUT name=' + this.id + ' value="' + Server.HTMLEncode(this._options[i].value) + '" type="radio" ';
					if (this._selectedIndex == i)
						strHTML += 'checked ';
					if (!this._options[i].disabled)
					{	// output client events to callback to server
						var strHandler = this._objEventManager.generateClientHandlers(this.name);	
						strHTML += strHandler;
					}
					else
						strHTML += ' disabled';
					strHTML += '><' + 'LABEL for="' + this.id + '" htmlfor="' + this.id;
					strHTML += '">' + this._options[i].text + '</LABEL>\n';
				}

				strHTML += '</TD>';
				if (this._nAlignment == '0')
					strHTML += '</TR>\n';
			}									

			if (this._nAlignment != '0')
				strHTML += '</TR>\n';
			strHTML += '</TABLE></TD></TR></TABLE>\n';
		}
		
		this._preserveState();
		if (bReturnText != true)
			Response.Write(strHTML);	// write display text to browser
		else
			return strHTML;				// return display text to caller
	}

	function _OPT__preserveState()
	{
		if (this.maintainState)
		{	// preserve state in hidden field
			var state = new Object;
			if (this._nBorder != 0)
				state._nBorder = this._nBorder;
			if (!this._bVisible)
				state._bVisible = false;
			if (this._nAlignment != 0)
				state._nAlignment = this._nAlignment;
			state._selectedIndex = this._selectedIndex;
			state._nCount = this._options.length;
			for (var i=0; i < this._options.length; i++)
			{
				state['t' + i] = this._options[i].text;
				if (this._options[i].value != this._options[i].text)
					state['v' + i] = this._options[i].value;
				if (this._options[i].disabled)
					state['d' + i] = true;
			}

			return thisPage.persistState(this.name,state);
		}
		return false;
	}

	function _OPT__restoreState()
	{
		var r = false;
		this._fireEvent(this._funcInit);
		if (this.maintainState)
		{	// attempt to restore previous state
			var state = thisPage.unpersistState(this.name);
			if (state != null)
			{
				this.clear();
				for (var i=0; i < state._nCount; i++)
				{
					this.addItem(state['t' + i],state['v' + i]);
					if (state['d' + i] != null)
						this._options[i].disabled = (state['d' + i] != '0' && state['d' + i] != 'false');
				}
				this._selectedIndex = Number(state._selectedIndex);
				if (state._nBorder != null)
					this._nBorder = state._nBorder;
				else
					this._nBorder = 0;

				if (state._bVisible != null)
					this._bVisible = (state._bVisible != '0' && state._bVisible != 'false');
				else
					this._bVisible = true;

				if (state._nAlignment != null)
					this._nAlignment = Number(state._nAlignment);
				else
					this._nAlignment = 0;

				r = true;
			}
		}
		var newValue = Request.Form(this.name) + '';
		if (newValue != 'undefined')
			this.selectByValue(newValue);
		return r;
	}

	function _OPT__hasState()
	{
		if (this.maintainState)
			return thisPage.isStatePersisted(this.name);
		return false;
	}

	// eventhandler for databinding
	function _OPT__onrowenter(objRecordset,strDataField)
	{
		this.selectByValue(objRecordset.fields.getValue(strDataField) + '');
	}

	// eventhandler for databinding
	function _OPT__onbeforeupdate(objRecordset,strDataField)
	{
		var value = this.getValue();
		if (typeof(value) != 'undefined' && value != null)
			objRecordset.fields.setValue(strDataField, value);
	}

}	// end of _OPT__Prototype function

</SCRIPT>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -