473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Array data taken from external files

Hi,

I am working on JS navigation for my web page. Contents of 3 subpages
are located in the array as shown below. When certain key is pressed on
the page, div is filled with data taken from one of the array rows.

***

var content=new Array()
content[1]='<p>some text</p>'
content[2]='<p>some other text</p>'
content[3]='<p>yet another text</p>'

***

The question is: is it possible in some simple way to put the data from
those 3 rows into 3 separate files and make the JS code to take the data
from those files? (I want to have 3 files with plain HTML) If so, please
show me some example how to do that. Or give me some address where I can
read about it, please. I have been using Google for several hours -
unfortunately without any luck.

In general - here is what I would like to do:

***

var content=new Array()
content[1]=[contents of '1.html' file]
content[2]=[contents of '2.html' file]
content[3]=[contents of '3.html' file]

***

How can I put the above into JS code?

--
Best wishes,
Doggie
Feb 22 '06 #1
3 1628
Doggie wrote:
The question is: is it possible in some simple way to put the data from
those 3 rows into 3 separate files and make the JS code to take the data
from those files? (I want to have 3 files with plain HTML)

var content=new Array()
content[1]=[contents of '1.html' file]
content[2]=[contents of '2.html' file]
content[3]=[contents of '3.html' file]


You don't have file access through JavaScript. But you can load data
from files *stored on the same host* by using a hidden iframe/frame or
that XMLHttpRequest object.

But since it's a menu you should do things in a very different way, you
can't make your site JavaScript dependent.

1. Output the menu as pure html.

<ul>
<li>
Menu A
<ul>
<li>Submenu 1</li>
<li>Submenu 2</li>
</ul>
</li>
<li>Menu B</li>
</ul>

2. Using JavaScript parse the structure, build your "cute" menu and
remove the old nodes.

That's the right way ;]
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Feb 22 '06 #2
Jonas Raoni wrote:
You don't have file access through JavaScript. But you can load data
from files *stored on the same host* by using a hidden iframe/frame or
that XMLHttpRequest object.

But since it's a menu you should do things in a very different way, you
can't make your site JavaScript dependent.

(...)

OK. Thanks for the help :)

--
Best wishes,
Doggie
Feb 23 '06 #3
Doggie wrote:
Jonas Raoni wrote:
You don't have file access through JavaScript. But you can load data
from files *stored on the same host* by using a hidden iframe/frame or
that XMLHttpRequest object.
But since it's a menu you should do things in a very different way,
you can't make your site JavaScript dependent.


(...)

OK. Thanks for the help :)


Nevermind, good luck and god bless the polish girls haha \o/
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Feb 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Leonardo Francalanci | last post by:
With mysql I know how much space a row will take, based on the datatype of it columns. I also (approximately) know the size of indexes. Is there a way to know that in postgresql? Is there a way...
3
by: eieiohh | last post by:
MySQL 3.23.49 PHP 4.3.8 Apache 2.0.51 Hi All! Newbie.. I had a CRM Open Source application installed and running. Windows Xp crashed. I was able to copy the contents of the entire hard...
0
by: jim4u | last post by:
I am porting a vb library to vb.net. The vb library has an external call to an unmanaged dll. Existing code: //External function declaration Private Declare Function Uncompress& Lib...
0
by: jim4u | last post by:
I am porting a vb library to vb.net. The vb library has an external call to an unmanaged dll. Existing code: //External function declaration Private Declare Function Uncompress& Lib...
29
by: foker | last post by:
I have this problem where I have 2 text files, one with student name, id#, # of courses and course #, the second file has course name and course number. I want to make a multidimensional array that...
10
by: Neville Lang | last post by:
Hi all, Here is a problem I first struck a while back in the Compact Framework. I am now using the full Framework (v2.0) and wanted to know whether there is anyway around this issue without...
30
by: josh | last post by:
Hi all, what does it meaning that strange sintax (look at the object :) ? if I have i.e. array.length I can use array. and is it IE/Firefox compatible??
15
by: mdh | last post by:
May I ask. If an array is defined , not as a static, but outside of a function, is there any guarantee as to the contents of each element? Thanks.
9
by: ssubbarayan | last post by:
Hi all, I am trying a program to convert floating point values to a byte array and printing the same to the screen.The idea behind this is we already have an existing function which can do byte...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.