PDA

View Full Version : javascript owning me help



dimeroll
04-18-2008, 08:12 PM
firefox says national[0][0][1] has no properties even though i made it an option element.

var national = new Array();
national[0] = new Array();
national[0][0] = new Array();
national[0] = "United States";
national[0][0] = document.createElement("option");
national[0][0].text = "United States";
national[0][0].value = "flags/usa.gif";
national[0][0][0] = document.createElement("option");
national[0][0][0].text = "5x9 - $9.99";
national[0][0][0].value = 9.99;
national[0][0][1] = document.createElement("option");
national[0][0][1].text = "10 x 18 - $34.99";
national[0][0][1].value = 34.99;
national[0][0][2] = document.createElement("option");
national[0][0][2].text = "50 x 90 - $934.99";
national[0][0][2].value = 934.99;

pulaskeet
04-19-2008, 06:37 AM
firefox says national[0][0][1] has no properties even though i made it an option element.

var national = new Array();
national[0] = new Array();
national[0][0] = new Array();
national[0] = "United States";
national[0][0] = document.createElement("option");
national[0][0].text = "United States";
national[0][0].value = "flags/usa.gif";
national[0][0][0] = document.createElement("option");
national[0][0][0].text = "5x9 - $9.99";
national[0][0][0].value = 9.99;
national[0][0][1] = document.createElement("option");
national[0][0][1].text = "10 x 18 - $34.99";
national[0][0][1].value = 34.99;
national[0][0][2] = document.createElement("option");
national[0][0][2].text = "50 x 90 - $934.99";
national[0][0][2].value = 934.99;

it's because you're trying to make an option inside an option

pulaskeet
04-19-2008, 06:42 AM
i dont know what youre trying to do, but i expanded on what i said to show you how it should look...



var national = new Array();
national[0] = new Array();
national[0][0] = new Array();
national[0] = "United States";
national[0][0] = document.createElement("option");
national[0][0].text = "United States";
national[0][0].value = "flags/usa.gif";
national[0][1] = document.createElement("option");
national[0][1].text = "5x9 - $9.99";
national[0][1].value = 9.99;
national[0][2] = document.createElement("option");
national[0][2].text = "10 x 18 - $34.99";
national[0][2].value = 34.99;
national[0][3] = document.createElement("option");
national[0][3].text = "50 x 90 - $934.99";
national[0][3].value = 934.99;


this makes an array of options... united states followed by 5x9 - 9.99, 10 x 18 - 34.99... etc

if you wanted them to be seperate lists, then incease the first part of the array (national[1][0] = ....; national[1][0] = "5x9 x 9.99";...)

dimeroll
04-19-2008, 05:08 PM
i dont know what youre trying to do, but i expanded on what i said to show you how it should look...



var national = new Array();
national[0] = new Array();
national[0][0] = new Array();
national[0] = "United States";
national[0][0] = document.createElement("option");
national[0][0].text = "United States";
national[0][0].value = "flags/usa.gif";
national[0][1] = document.createElement("option");
national[0][1].text = "5x9 - $9.99";
national[0][1].value = 9.99;
national[0][2] = document.createElement("option");
national[0][2].text = "10 x 18 - $34.99";
national[0][2].value = 34.99;
national[0][3] = document.createElement("option");
national[0][3].text = "50 x 90 - $934.99";
national[0][3].value = 934.99;


this makes an array of options... united states followed by 5x9 - 9.99, 10 x 18 - 34.99... etc

if you wanted them to be seperate lists, then incease the first part of the array (national[1][0] = ....; national[1][0] = "5x9 x 9.99";...)

I'm planning to use three arrays. Dimension 1 simply holding a string for indexing purposes, dimension2 holding an option element with the name of the country and the value holding a path to a gif of its flag, dimension three an array of options holding flag description w/ price in the value section.

dimeroll
04-19-2008, 05:12 PM
it's because you're trying to make an option inside an option

so ur saying when i make [0][0] into an option element, that [0][0][0] is created because the option object has an array in itself?

btw <3 delilah

dimeroll
04-19-2008, 05:13 PM
i dont know what youre trying to do, but i expanded on what i said to show you how it should look...



var national = new Array();
national[0] = new Array();
national[0][0] = new Array();
national[0] = "United States";
national[0][0] = document.createElement("option");
national[0][0].text = "United States";
national[0][0].value = "flags/usa.gif";
national[0][1] = document.createElement("option");
national[0][1].text = "5x9 - $9.99";
national[0][1].value = 9.99;
national[0][2] = document.createElement("option");
national[0][2].text = "10 x 18 - $34.99";
national[0][2].value = 34.99;
national[0][3] = document.createElement("option");
national[0][3].text = "50 x 90 - $934.99";
national[0][3].value = 934.99;


this makes an array of options... united states followed by 5x9 - 9.99, 10 x 18 - 34.99... etc

if you wanted them to be seperate lists, then incease the first part of the array (national[1][0] = ....; national[1][0] = "5x9 x 9.99";...)

hmm i'ma have to rethink my array schema

dimeroll
04-19-2008, 05:24 PM
Hmm well i could make two seperate arrays
national

[0]United States-string
[0][0]USA-option element
[0][1]Texas-option element
[0][2]New York-option element
[1]Mexico
[1][0]Mexico-option element
[2][1]Mexican State-option element
[2]Canada
[2][0]Canada-option element
[2][1]Ontario-option element
ect....

then another array called
prices
[0]United States -string
[0][0]2x5 - option element
[0][1]9x16 - option element
[1]Texas - String
[1][0]2x5 - option element
[1][1]9x16 - option element

id really like them in the same array tho for speed

dimeroll
04-19-2008, 05:29 PM
ultimate goal is to slang flags

pulaskeet
04-19-2008, 09:28 PM
you might have missed what I was saying. Pm me with your aim, I'll explain more thoroughly on aim (I'd post here but I'm on my iPhone)

qbert
04-20-2008, 12:42 AM
man pulaskeet, you are too nice

chewy, you're an idiot

good luck slanging flags

pulaskeet
04-20-2008, 12:48 AM
man pulaskeet, you are too nice

chewy, you're an idiot

good luck slanging flags

lol yea maybe but i learned all the coding i know online. back in pr vb, people used to be cool with info, so i try to keep that going