M
mark4asp
How can I use name:value pairs like an array?
1. I want to load data on to the page which will be used to populate a
list box (see example below):
<html>
<head>
<script type="text/javascript">
var aInvestor = {1448:"4Imprint Group plc Pension Scheme",
1061:"Aargau Pensionskasse",659:"ABB Koncernens Pensionsstiftelse",
44:"ABB Pensionskasse",387:"Abbey National PLC Amalgamated Pension
Funds",1092:"ABBs Pensjonskasse"}
function init()
{
for (var code in aInvestor)
document.getElementById('selII').options.add(new
Option(aInvestor
1. I want to load data on to the page which will be used to populate a
list box (see example below):
<html>
<head>
<script type="text/javascript">
var aInvestor = {1448:"4Imprint Group plc Pension Scheme",
1061:"Aargau Pensionskasse",659:"ABB Koncernens Pensionsstiftelse",
44:"ABB Pensionskasse",387:"Abbey National PLC Amalgamated Pension
Funds",1092:"ABBs Pensjonskasse"}
function init()
{
for (var code in aInvestor)
document.getElementById('selII').options.add(new
Option(aInvestor
Code:
,code));
}
</script>
</head>
<body onload="init();">
<select size="6" name="selII" id="selII"></select>
</body>
</html>
2. I also want to be able to carry out a binary search on the text in
the object (aInvestor).
The final purpose of this is to allow the user to do an incremental
search on the aInvestor items such that only those items are currently
shown in the list box.
eg. typing "a" will show all items beginning with "a", typing "ab"
shows only all those items beginning with "ab", etc.
The aInvestor is populated on the server.
My problem is that the aInvestor doesn't have a length property and I
need that to do my binary search - how can I get around this problem?
PS: The code need only work with IE (as there are only about 1000
clients who are all corporate microserfs).