I need help, im sure the solution is simple, but it's driving me nuts. Im trying to retrieve the value of js_array['pearl']['a'] using js_array['pearl'][selectedObj.sel ectedIndex]; where selectedObj.sel ectedIndex is a string value from a select box. I need to wrap quotes around selectedObj.sel ectedIndex for it to retrieve the associative key properly, but everything ive tried has failed. This works fine if the key is numeric, but fails if the key is a string. I'm sorry if I didn't explain this very well, my brain is kind of fried today. Can someone please help me???
Code:
<script language='JavaScript'>
var js_array = new Array();
js_array['stain'] = new Array();
js_array["pearl"]["a"] = "pearla.jpg";
function pearlchange(selectedObj){
document.pearlimg.src=imgDir + js_array['pearl'][selectedObj.selectedIndex];
}
</script>
<form>
<select name="pearl" onchange='pearlchange(this)' >
<option value='a'>Violet (a)</option>
</select>
</form>
<img name='pearlimg' src="" />
Comment