Not sure why collection myCol is showing undefind when I try to run alert(myCol.count).
<html>
<head>
<title>testing testing </title>
</head>
<script type="text/javascript">
function Collection() {
var collection = {};
var order = [];
this.add = function(property, value) {
if (!this.exists(property)) {
collection[property] = value;
order.push(property);
}
}
this.remove = function(property) {
collection[property] = null;
var ii = order.length;
while (ii-- > 0) {
if (order[ii] == property) {
order[ii] = null;
break;
}
}
}
this.toString = function() {
var output = [];
for (var ii = 0; ii < order.length; ++ii) {
if (order[ii] != null) {
output.push(collection[order[ii]]);
}
}
return output;
}
this.getKeys = function() {
var keys = [];
for (var ii = 0; ii < order.length; ++ii) {
if (order[ii] != null) {
keys.push(order[ii]);
}
}
return keys;
}
this.update = function(property, value) {
if (value != null) {
collection[property] = value;
}
var ii = order.length;
while (ii-- > 0) {
if (order[ii] == property) {
order[ii] = null;
order.push(property);
break;
}
}
}
this.exists = function(property) {
return collection[property] != null;
}
}
function OnChange(dropdown)
{
var myindex = dropdown.selectedIndex
var SelValue = dropdown.options[myindex].value
console.log("testingtesting");
alert('my index is ' + myindex);
alert('my value is ' + SelValue);
var myCol=new Collection();
myCol.add("A",0);
myCol.add("B",1);
myCol.add("C",2);
alert(myCol.count);
alert("test");
}
</SCRIPT>
<body>
<form>
<table>
<tr><td><input type="radio" name="sex" value="male">Male</tr></td>
<tr>
<td>test o Date:</td>
<td><select name="oDateStr">
<option value="" selected="selected"></option>
<option value='06/16/2013'>06/16/2013</option>
<option value='01/01/2013'>01/01/2013</option></select>
</td>
<td>test a Date:</td>
<td>
<select name="aDateStr" onchange="OnChange(this.form.aDateStr)">
<option value="" selected="selected"></option>
<option value='07/01/2013'>07/01/2013</option>
<option value='06/19/2013'>06/19/2013</option>
<option value='06/18/2013'>06/18/2013</option>
<option value='01/10/2013'>01/10/2013</option>
<option value='01/01/2013'>01/01/2013</option>
</select>
</td>
</tr>
</table>
</form>
</body>
</html>
Howard
<html>
<head>
<title>testing testing </title>
</head>
<script type="text/javascript">
function Collection() {
var collection = {};
var order = [];
this.add = function(property, value) {
if (!this.exists(property)) {
collection[property] = value;
order.push(property);
}
}
this.remove = function(property) {
collection[property] = null;
var ii = order.length;
while (ii-- > 0) {
if (order[ii] == property) {
order[ii] = null;
break;
}
}
}
this.toString = function() {
var output = [];
for (var ii = 0; ii < order.length; ++ii) {
if (order[ii] != null) {
output.push(collection[order[ii]]);
}
}
return output;
}
this.getKeys = function() {
var keys = [];
for (var ii = 0; ii < order.length; ++ii) {
if (order[ii] != null) {
keys.push(order[ii]);
}
}
return keys;
}
this.update = function(property, value) {
if (value != null) {
collection[property] = value;
}
var ii = order.length;
while (ii-- > 0) {
if (order[ii] == property) {
order[ii] = null;
order.push(property);
break;
}
}
}
this.exists = function(property) {
return collection[property] != null;
}
}
function OnChange(dropdown)
{
var myindex = dropdown.selectedIndex
var SelValue = dropdown.options[myindex].value
console.log("testingtesting");
alert('my index is ' + myindex);
alert('my value is ' + SelValue);
var myCol=new Collection();
myCol.add("A",0);
myCol.add("B",1);
myCol.add("C",2);
alert(myCol.count);
alert("test");
}
</SCRIPT>
<body>
<form>
<table>
<tr><td><input type="radio" name="sex" value="male">Male</tr></td>
<tr>
<td>test o Date:</td>
<td><select name="oDateStr">
<option value="" selected="selected"></option>
<option value='06/16/2013'>06/16/2013</option>
<option value='01/01/2013'>01/01/2013</option></select>
</td>
<td>test a Date:</td>
<td>
<select name="aDateStr" onchange="OnChange(this.form.aDateStr)">
<option value="" selected="selected"></option>
<option value='07/01/2013'>07/01/2013</option>
<option value='06/19/2013'>06/19/2013</option>
<option value='06/18/2013'>06/18/2013</option>
<option value='01/10/2013'>01/10/2013</option>
<option value='01/01/2013'>01/01/2013</option>
</select>
</td>
</tr>
</table>
</form>
</body>
</html>
Howard