I have another problem now. FF doesn't like it when I assign a numeric "key" to my object. What am I doing wrong here?
-
var stain = {};
-
var pearl = {};
-
stain.1 = 'stain1.jpg'; //This produces a 'missing ; before statement' error
-
pearl.a = 'pearla.jpg'; //This works fine
-
I'm also having problem with using a variable as my object "key" value:
-
-
var optionImg = {};
-
var pearl = {};
-
pearl.a = 'pearla.jpg';
-
pearl.b = 'pearlb.jpg';
-
pearl.c = 'pearlc.jpg';
-
pearl.e = 'pearle.jpg';
-
pearl.f = 'pearlf.jpg';
-
pearl.g = 'pearlg.jpg';
-
pearl.h = 'pearlh.jpg';
-
optionImg.pearl = pearl;
-
alert(optionImg.toSource());
-
var imgDir='http://vikingcue.com/images/options/';
-
-
-
function pearlChange(selectedObj){
-
var testpath=imgDir + optionImg.pearl.selectedObj;
-
alert(selectedObj in optionImg.pearl.toSource());
-
alert(testpath.toSource());
-
}
-
I need the selectObj variable to reference the key, instead I get the error: optionImg.pearl.selectedObj is undefined. I'm sorry if these questions are elementary, I'm just trying to learn a few things here.
Here is the select box:
<select onChange='pearlChange(this.value)>
<option value='a'>Pearl A</option>
</select>
Thanks,
Justin