Confused Idiot
10-24-2006, 11:36 PM
Hello, I'm new here and was hoping for a little help with something. I have no background in programming anything, so please don't shoot me down for using bad terms or thinking in a completely wrong way.
I've been reading parts of tutorials and other peoples' code in order to get a basic grasp of the language, and have run into the problem which follows.
One array is like this:
typ = new Array();
typ[0] = ("One");
typ[1] = ("Two");
typ[2] = ("Three");
Another is like this:
var item = new Array();
function obj_item(name, type)
//^Questioning the above - does obj_xx need to be the same as the array? Remember, I'm mostly learning from other peoples' code.
{
this.name = name;
this.type = type;
}
item[0] = new obj_ar2("Item1",1);
What I'd like to do is have "type" from the "item" array display what is in the "typ" array.
document.write(item[0].type);just returns "1", and I'd like to know how to return "Two". So I'm getting the right value, I just don't know how to use that value to write what is in the other array.
I've been trying things for hours, and searched all over the place, but not really knowing what I'm doing doesn't help as far as search terms go. Hopefully someone will understand what I'm trying to say/do.
Thanks a lot for any help, please remember I'm quite clueless and will probably be asking more questions in future.
I've been reading parts of tutorials and other peoples' code in order to get a basic grasp of the language, and have run into the problem which follows.
One array is like this:
typ = new Array();
typ[0] = ("One");
typ[1] = ("Two");
typ[2] = ("Three");
Another is like this:
var item = new Array();
function obj_item(name, type)
//^Questioning the above - does obj_xx need to be the same as the array? Remember, I'm mostly learning from other peoples' code.
{
this.name = name;
this.type = type;
}
item[0] = new obj_ar2("Item1",1);
What I'd like to do is have "type" from the "item" array display what is in the "typ" array.
document.write(item[0].type);just returns "1", and I'd like to know how to return "Two". So I'm getting the right value, I just don't know how to use that value to write what is in the other array.
I've been trying things for hours, and searched all over the place, but not really knowing what I'm doing doesn't help as far as search terms go. Hopefully someone will understand what I'm trying to say/do.
Thanks a lot for any help, please remember I'm quite clueless and will probably be asking more questions in future.