473,721 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1312
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="javas cript"
!
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="javas cript"
!


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/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
Lasse Reichstein Nielsen wrote:
language="jav ascript"
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.******@blueyo nder.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.lengt h;i++)prt+=rec[i]+'<br>';
tuc=window.open (); tuc.document.wr ite(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,Florenc e 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=re c[4]; alert(ptr);">De gge</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=re c[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
3265
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)) CType(local4, Short) = CType(src, Short)
9
4803
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 am using vector class(STL), the compiler does not allow me to do this. I do realize there is a pitfall in this approach(size of arrays not matching etc), but I wonder how to get around this problem. I have a class hierachy with abstract base...
5
2216
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 1,1,2,4. I have narrowed it down to the sort function. I'm almost positive
8
4608
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 later on. Before that happens there has been a problem that causes a crash of the program. This is a little program "test.exe" I wrote to test what happens. compiler: mingw 3.1.01 for win32 command line
12
5518
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 following program: #include<stdio.h> #define SIZE 1 int main()
204
13038
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 = {0,1,2,4,9};
8
10717
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 receive a byte array as one of its parameters. The project is marked for COM interop, and that all proceeds normally. When I reference the type library in the VB6 project, and write the code to call the function that returns the byte array, it works
104
16984
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 that array Could you show me a little example how to do this? Thanks.
23
7410
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 in an array. The application compiles but aborts without giving me any useful information. What I suspect is happening is infinite recursion. Each Directory object creates an array of Subdirectories each of which has an array of...
4
1982
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) a display function on the HTML form and
0
8851
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9077
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8019
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6676
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5992
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4497
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4761
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3202
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2137
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.