listbox - o[nIdx].value = o[nIdx - 1].value; } o[pos] = new...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* REM JavaScript functions for client-side manipulation of HTML listboxes. REM Works on both NetScape (4.0+) and IE (4.0+). REM Look at \source\misc\ymmbuild.asp for an example of how to use these functions. */ function clearList(list) { var i = 0; var o = list.options; if (null != o) { for (i = o.length; i >= 0; --i) o[i] = null; } list.disabled = true; } function addElement(list, text_in, value_in) { var o = list.options; var nIdx; if (o.length < 0) //IE for Mac 4.5 sets length to -1 if list is empty nIdx = 0; else nIdx = o.length; o[nIdx] = new Option(text_in, value_in); list.disabled = false; } function addElementAtPos(list, pos, text_in, value_in) { var o = list.options; var nIdx = 0; if ((pos < 0) || (pos > o.length)) return; addElement(list, '', ''); for (nIdx = o.length - 1; nIdx > pos; nIdx--) { o[nIdx].text = o[nIdx - 1].text;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: o[nIdx].value = o[nIdx - 1].value; } o[pos] = new Option(text_in, value_in); list.disabled = false; } function setDefaultByText(list, text_in) { with (list) { for (var i = 0; i &lt; (options.length); i++) { if (options[i].text == text_in) { selectedIndex = i; return; } } } } function setDefaultByIText(list, text_in) { with (list) { if(options.length &gt; 0) selectedIndex = 0; // in case desired text_in value is not present, set a default for (var i = 0; i &lt; (options.length); i++) { if (options[i].text.toLowerCase() == text_in.toLowerCase()) { selectedIndex = i; return; } } } } function setDefaultByValue(list, value_in) { with (list) { for (var i = 0; i &lt; (options.length); i++) { if (options[i].value == value_in) { selectedIndex = i; return; } } } }...
View Full Document

Page1 / 2

listbox - o[nIdx].value = o[nIdx - 1].value; } o[pos] = new...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online