/    Sign up×
Community /Pin to ProfileBookmark

using data in an array through a site

Hi all,?

i’ve got some array’s…
I want to use the data through the website.
The data is in data.js
the for staments in elm.js
and there is text in text.js with image links.
the array are used to create a Tab element
after loading there’s a link panel created with the myArray var
then the Tab’s are named with ‘test_1’ and the Tab page content with the ‘A1’.
In the A1 content is text and images the link should be
like “myArray/test/A1/myImage.jpg”
But I just cant get the array past outside the for statement’s.

var myArray=new Array(‘test’,’test_1′,’test_2′);
var test=new Array(‘A1′,’A2′,’A3′,’A4’);
var test_1=new Array(‘B1′,’B2′,’B3′,’B4’);
var test_2=new Array(‘C1′,’C2′,’C3′,’C4’);
A1=”a1″;
A2=”a2″;
A3=”a3″;
A4=”a4″;
B1=”b1″;
B2=’b2′;
B3=’b3′;
B4=’b4′;
C1=’c1′;
C2=’c2′;
C3=’c3′;
C4=’c4′;
var Link=”;

for(var b=0;b<myArray.length;b++){
var n=eval(Array[b]);
for(var q=0;q<n.length;q++){
var u=eval(n[q]);
Link=Array[b]+’/’+n[q]+’/’;
[COLOR=crimson]alert(“this is link … “+Link);[/COLOR]
}
}
[COLOR=crimson]alert(“this is link … “+Link);[/COLOR]

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@David_HarrisonSep 19.2003 — Firstly n is not an array:

var u=eval(n[q]);

and even if it was, you wouldn't need the eval, same goes for the other eval:

var n=eval(Array[b]);



Another blinding error is that you don't have an array called Array. You have one called myArray if that is the one you were referring to.



Also this line:



Link=Array[b]+'/'+n[q]+'/';



notice the n[q], well if we substitute in what n is we get this:



Array[b][q]



This is a non-existant 2 dimentional array.



So no wonder your code doesn't work, it's riddled with errors. If you tell me what the general effect you're trying to achieve is, I'll write some code for you, or if you would prefer I will simply point you in the right direction.
Copy linkTweet thisAlerts:
@eddy_eikelauthorSep 20.2003 — Hi your right, made it work ?

But i still need a way to use the data throughout my site

//////////////////////////////////////////

var myArray=new Array('mysql','php','perl');

var mysql=new Array('A1','A2','A3','A4');

var php=new Array('B1','B2','B3','B4');

var perl=new Array('C1','C2','C3','C4');

var A1=new Array("Atest1");

var A2=new Array("Atest2");

var A3=new Array("Atest3");

var A4=new Array("Atest4");

var B1=new Array("Btest1");

var B2=new Array('Btest2');

var B3=new Array('Btest3');

var B4=new Array('Btest4');

var C1=new Array('Ctest1');

var C2=new Array('Ctest2');

var C3=new Array('Ctest3');

var C4=new Array('Ctest4');

Atest1="A-test1 this is text for the site";

Atest2="A-test2 this is text for the site";

Atest3="A-test3 this is text for the site";

Atest4="A-test4 this is text for the site";

Btest1="B-test1 this is text for the site";

Btest2="B-test2 this is text for the site";

Btest3="B-test3 this is text for the site";

Btest4="B-test4 this is text for the site";

Ctest1="C-test1 this is text for the site";

Ctest2="C-test2 this is text for the site";

Ctest3="C-test3 this is text for the site";

Ctest4="C-test4 this is text for the site";


var Link='';

for(var b=0;b<myArray.length;b++){

var n=eval(myArray[b]);

for(var q=0;q<n.length;q++){

var u=eval(n[q]);

Link=myArray[b]+'/'+n[q]+'/';

alert("this is link inside the for statement... "+Link);

}

}

alert("this is link outside the for statment... "+Link);

/////

the data is used like this ...

nav.panel=createElm(nav,5,((b+1)*24),bodyWidth()/8-14,22);

nav.panel.setHTML('<div class="panel"><a href="javascript:onclick('+myArray[b]+')"><center>'+myArray[b]+'</a></div><br/>');

//baseref=myArray[b];

//src=baseref+'/'+n[q]+'/';

if(i==0){tab.addPage(n[q],u);}

onclick=function(tet){

tab.remove();

tab=Tab(null,null,180,80,820,540,"red");

for(var g=0;g<tet.length;g++){ var r=eval(tet[g]);

//src=baseref+'/'+tet[g]+'/';

tab.addPage(tet[g],r);





///////////////////////////////////////////:rolleyes:
Copy linkTweet thisAlerts:
@David_HarrisonSep 20.2003 — What do you mean by "use the data throughout my site", as long as you don't write over anything in the array all the data is still accessible.
Copy linkTweet thisAlerts:
@eddy_eikelauthorSep 20.2003 — What do you mean by "use the data throughout my site", as long as you don't write over anything in the array all the data is still accessible.[/QUOTE]

Hi ?

That's the problem, I can't use the data out side the for statements after the last '}'.

see the alert message

alert nr. 1 shows the complete array

2 doesn't

?

the idea is to use data in the array and create all the elements using this data, i also want to make the links to diffrent documents and images using this data.

===============================

array 1 =>> parent 1,p2,p3

array2 => childnode1,C2,C3

array3 => Child-childnode,CC1,CC2

parent

childnode

childnode

loading an external textfile onclick

link=> /parent/childnode/childchildnode/childchildnode_txt.js

and

ImageLink like:

/parent/childnode/childchildnode/this_image_NAME.jpg

so create a couple of array's and

use them through the site to create object names and link and image ref's.

hope you understand what i like to do...







:rolleyes:
Copy linkTweet thisAlerts:
@eddy_eikelauthorSep 20.2003 — checkout : [URL=http://home.deds.nl/~daihard/index.html]mysite[/URL]

goto -> Information

and then AddingFuel or turbo

when you click on

[U]more ->[/U]

then a new 'window opens with a long text .

maybe you understand better how i want it to get it working nicely

? :p ?
Copy linkTweet thisAlerts:
@David_HarrisonSep 20.2003 — Next problem, Link is not an array, link is just a variable. This means that on this line:

Link=myArray[b]+'/'+n[q]+'/';



every time the for loop runs Link is assigned a new value. This is why it shows up in the alert in the for loop but outside the loop that alert only show's the last value that was assigned to the variable Link.



I suggest changing the line above, into this:



Link[(n.length-1)*b+q]=myArray[b]+'/'+n[q]+'/';



and before the loop have this;



var Link=new Array();



and if you want to show all of the values assigned to the link array in an alert have this:



alert(Link.join(", "));
×

Success!

Help @eddy_eikel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...