473,394 Members | 1,749 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,394 software developers and data experts.

array problem

I have an external javascript file named record.js in the file is the
following sample:

rec[0]="Blake, Agnes, 18 Sep 1909";
rec[1]="Boyes, Florence Edith, 1885";
rec[2]="Carter, Kathleen Sybil, 1910";
rec[3]="Carty, Joseph, ??";
rec[4]="Degee, Ann, ??";

I would access the script with the following
<SCRIPT SRC="record.js"></SCRIPT>
What I have failed to do so far is print any of the
files contents ( the full list is 163 names ) I think the best method
would be to pass a variable to a function and have the function return
the string point to by the variable something like
ptr=4
the function would return a string containing "Degee, Ann, ??";

I have had spectacular success in getting none of it to work,
I don't and would not ask for others to do it for me, but would
someone point me in the right direction,

In parting may I ask would it be better to create a table (containing
the elements from the above function, if i ever get it working ) in
the external file or on the html page that it is called from.

any help would be great fully relieved, and may save my hairline
Jul 20 '05 #1
6 1303
Trevor Stapleton wrote:
I have an external javascript file named record.js in the file is the
following sample:
with as its first line

var rec = new Array;

I hope?
rec[0]="Blake, Agnes, 18 Sep 1909";
rec[1]="Boyes, Florence Edith, 1885";
rec[2]="Carter, Kathleen Sybil, 1910";
rec[3]="Carty, Joseph, ??";
rec[4]="Degee, Ann, ??";

I would access the script with the following
<SCRIPT SRC="record.js"></SCRIPT>
add the phrase (attribute)
language="javascript"
!
I have had spectacular success in getting none of it to work,
great expression <G> What browser do you use? I use Mozilla, has a nice
javascript console. Netscape probably has one, too. Helps enormously in
debugging.
In parting may I ask would it be better to create a table (containing
the elements from the above function, if i ever get it working ) in
the external file or on the html page that it is called from.


Don't understand. So, you want to create a TABLE tag (with all elements)
and in there use the data from the record.js script?

It depends. I think that is a small collection of functions for the job,
you can put it in the document itself. Maybe you are going to use the
functionality more often, in which case you might transfer most of it to
a separate file.

--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Jul 20 '05 #2
Bas Cost Budde <ba*@heuveltop.org> writes:
add the phrase (attribute)
language="javascript"
!


Preferably, add
type="text/javascript"
The type attribute is required in HTML 4, and is sufficient in all
versions. The language attribute is deprecated and should be omitted.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
Lasse Reichstein Nielsen wrote:
language="javascript"
Preferably, add
type="text/javascript"
The type attribute is required in HTML 4, and is sufficient in all
versions. The language attribute is deprecated and should be omitted.

/L

You are extremely right of course! Why didn't I see that myself. Thanks.
I'm a little ashamed because where I am aware of deprecated features, I
rather strongly hammer them.

How about the necessity of whatever type/language indication? Do you
know browsers that choke on the script if the specifier is absent? I
just tried in Moz en IE but they execute anyway.

--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Jul 20 '05 #4
On Tue, 03 Feb 2004 09:33:41 +0100, Bas Cost Budde <ba*@heuveltop.org>
wrote:

[snip]
How about the necessity of whatever type/language indication? Do you
know browsers that choke on the script if the specifier is absent? I
just tried in Moz en IE but they execute anyway.


The "major" browsers certainly work without a type: they just default to
JavaScript. I would imagine that recent "minor" browsers would follow suit
for compatibility reasons. But, as we all know, just because it works, it
doesn't make it right!

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #5
On Mon, 02 Feb 2004 21:22:55 +0100, Bas Cost Budde <ba*@heuveltop.org>
wrote:
In the interest of clarity i think I have better try and explain what
i am attempting to do:
-------------------------------------------------------------------
I have a list of 163 names held in an array named "rec" and indexed as
shown below, I have declared three variables to use in manipulating (
when it get it to work) the array.
What i want to happen is this, a visitor to my site would click on a
letter of the alphabet for example the letter "D" i want the
html/javascript to display all the surnames starting with the letter
"D" in a table, that is the basic task i have set myself, I will
refine it later to strip the string info smaller sections each in a
predefined cell of it's own and offering a link to view the entire
page relating to a name chosen by the visitor, I think I could do this
quite easily in Visual Basic, but as i am trying to learn ( oh so
slowly) java script, i feel it's worth staying with.

the data is held in an external file named record.js I decided to use
an external file because i think ( right or wrong ) it would be easier
to keep updated, and i don't like the way it seems to overload the
html page sticking all that info in the head section.

I could realy do with some clarity on where the actual table and
printing to screen should take place, should it be in the .js file or
on the html page?
below is the top section of my record.js page
--------------------------------------------------------------
var rec=new Array();
var firstrec=0;
var lastrec=0;
var totrec=0;

rec[0]="Blake, Agnes, 18 Sep 1909";
rec[1]="Boyes, Florence Edith, 1885";
rec[2]="Carter, Kathleen Sybil, 1910";
rec[3]="Carty, Joseph, ??";
rec[4]="Degee, Ann, ??";
rec[5]="Devlin, Joseph, ??";
rec[6]="Devlin, Ryan 1993, ??";
rec[7]="Fancy, Ann, ??";
rec[8]="Fancy, Ann, ??";
rec[9]="Fancy, Anne, 1834";
rec[10]="Fancy, Elizabeth, ??";
Jul 20 '05 #6
@SM
Trevor Stapleton a ecrit :

I have an external javascript file named record.js in the file is the
following sample:

rec[0]="Blake, Agnes, 18 Sep 1909";
rec[1]="Boyes, Florence Edith, 1885";
rec[2]="Carter, Kathleen Sybil, 1910";
rec[3]="Carty, Joseph, ??";
rec[4]="Degee, Ann, ??";

I would access the script with the following
<SCRIPT SRC="record.js"></SCRIPT>
What I have failed to do so far is print any of the
files contents ( the full list is 163 names ) I think the best method
would be to pass a variable to a function and have the function return
the string point to by the variable something like
ptr=4
<a href="#" onclick="prt='';
for(var i=0;i<rec.length;i++)prt+=rec[i]+'<br>';
tuc=window.open(); tuc.document.write(prt);">See all records</a>
???
the function would return a string containing "Degee, Ann, ??";


First
would be better moving away each space after coma in your records
rec[1]="Boyes,Florence Edith,1885";
rec[4]="Degee,Ann,??";
(facultative)

Then ...
For instance (to get one of this records) ==>

simplest :
<a href="#" onclick="alert(rec[4]);">Degge</a>
or to use your way :
<a href="#" onclick="ptr=rec[4]; alert(ptr);">Degge</a>
or :
<a href="#" onclick="ptr=4; alert(rec[ptr]);">Degge</a>

or where you want to write a reccord in your page :
<script type="text/javascript">
document.write(rec[4]);
</script>

More difficult :
Name of <a href="#"
onclick="ptr=rec[4].plit(','); alert(prt[0]);">Ann</a>
More examples here :
http://perso.wanadoo.fr/stephane.mor...c/reccords.htm
- open in a window
- search a record (by name, surname or year)
- make a listbox (uuu ! 163 options !)

--
******** (enlever/remove [OTER_MOI] du/from reply url) *******
Stéphane MORIAUX : mailto:st*********************@wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephane.moriaux/internet/
************************************************** ************
Jul 20 '05 #7

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

Similar topics

7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
9
by: justanotherguy63 | last post by:
Hi, I am designing an application where to preserve the hierachy and for code substitability, I need to pass an array of derived class object in place of an array of base class object. Since I...
5
by: ritchie | last post by:
Hi, I am writing to ask if anyone can see why my array is not being sorted correctly? It's an array of 4 elements(ints 1,2,3,4) but after calling the selection sort it comes back sorted as...
8
by: Gerald | last post by:
I have a problem with an array of pointers. In a program I'm writing, I have to read a file, containing thousands of short lines. The content of another file will be compared against each line...
12
by: arkobose | last post by:
my earlier post titled: "How to input strings of any lengths into arrays of type: char *array ?" seems to have created a confusion. therefore i paraphrase my problem below. consider the...
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
4
by: assgar | last post by:
Hi Seasons Greetings Its back, I am being haunted. I thought I had resolved this problem but I am intermittently the receving the warnings below. This code consist of a 1) HTML form, 2)...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.