473,320 Members | 2,027 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,320 software developers and data experts.

Could use some help with a link problem.

Amy
Hello this script was switched to one with a timer. But now it doesn't
work right. The items in the left are supposed to be the link names,
and the items in the right are supposed to be the link addresses. When
it was switched from a day rotation to a timed rotation something is
keeping it from working as a link. Can anyone see why? Please let me
know, thanks, Amy
one that works by day just following and works correctly. <BODY
onload="changelink();"><a href="#" id="url"></a>

var arr = [
["Link name google web site"],["http://www.google.com"],
["two link"],["http://www.yahoo.com"]
];

now = new Date();
nowDate = now.getDate();
function changelink(){
if (nowDate*2 arr.length) return;
document.getElementById("url").href = arr[nowDate*2-1][0];
document.getElementById("url").appendChild(documen t.createTextNode(arr[nowDate*2-2][0]));
}
The following works by milliseconds. It only switches from the left
item to the right item
but left item isn't a link to the right item like it is supposed to be.
Can anyone help me fix it? Thank you very much. <BODY
onload="changelink();"><a href="#" id="url"></a>
var arr = [
["Link name google web site"],["http://www.google.com"],
["two link"],["http://www.yahoo.com"]
];
var dynLink = null;

function init() {
dynLink = document.getElementById('url');
window.setTimeout('changeURL(0)',1000);
}

function changeURL(i) {
if (i >= arr.length) {
i = 0;
}
dynLink.innerHTML = arr[i][0];
dynLink.href = arr[i][1];
window.setTimeout('changeURL('+(++i)+')',1000);
}
window.onload = init;

Nov 3 '06 #1
8 1203
Lee
Amy said:
>
Hello this script was switched to one with a timer. But now it doesn't
work right. The items in the left are supposed to be the link names,
and the items in the right are supposed to be the link addresses. When
it was switched from a day rotation to a timed rotation something is
keeping it from working as a link. Can anyone see why?
>var arr = [
["Link name google web site"],["http://www.google.com"],
["two link"],["http://www.yahoo.com"]
];
>function changeURL(i) {
if (i >= arr.length) {
i = 0;
}
dynLink.innerHTML = arr[i][0];
dynLink.href = arr[i][1];
window.setTimeout('changeURL('+(++i)+')',1000);
}
window.onload = init;
Ask your instructor to explain arrays more clearly.
You don't seem to understand what these mean:
arr[i][0]
arr[i][1]
--

Nov 4 '06 #2
Amy
Can't you just tell me what you're trying to say, many of us don't have
instructors, I did a google search and I still don't know how to fix
it.
Lee wrote:
Amy said:

Hello this script was switched to one with a timer. But now it doesn't
work right. The items in the left are supposed to be the link names,
and the items in the right are supposed to be the link addresses. When
it was switched from a day rotation to a timed rotation something is
keeping it from working as a link. Can anyone see why?
var arr = [
["Link name google web site"],["http://www.google.com"],
["two link"],["http://www.yahoo.com"]
];
function changeURL(i) {
if (i >= arr.length) {
i = 0;
}
dynLink.innerHTML = arr[i][0];
dynLink.href = arr[i][1];
window.setTimeout('changeURL('+(++i)+')',1000);
}
window.onload = init;

Ask your instructor to explain arrays more clearly.
You don't seem to understand what these mean:
arr[i][0]
arr[i][1]
--
Nov 5 '06 #3
ASM
Amy a écrit :
Can't you just tell me what you're trying to say, many of us don't have
instructors, I did a google search and I still don't know how to fix
it.
ask to google : javascript array two dimensions
>Amy said:
>>Hello this script was switched to one with a timer. But now it doesn't
work right. The items in the left are supposed to be the link names,
and the items in the right are supposed to be the link addresses. When
it was switched from a day rotation to a timed rotation something is
keeping it from working as a link. Can anyone see why?
var arr = [
[["Link name google web site"],["http://www.google.com"]],
[["two link"],["http://www.yahoo.com"]]
];
>>function changeURL(i) {
if (i >= arr.length) {
i = 0;
}
dynLink.innerHTML = arr[i][0];
dynLink.href = arr[i][1];
window.setTimeout('changeURL('+(++i)+')',1000) ;
}
window.onload = init;
Ask your instructor to explain arrays more clearly.
You don't seem to understand what these mean:
arr[i][0]
arr[i][1]
--
Nov 5 '06 #4
ASM wrote:
Amy a écrit :
>Can't you just tell me what you're trying to say, many of us don't have
instructors, I did a google search and I still don't know how to fix
it.
I assume you didn't read my second post in your previous thread, then?

[snip]
var arr = [
[["Link name google web site"],["http://www.google.com"]],
[["two link"],["http://www.yahoo.com"]]
];
That wouldn't be right, either.

[snip]

Mike
Nov 5 '06 #5

Amy wrote:
Hello this script was switched to one with a timer. But now it doesn't
work right. The items in the left are supposed to be the link names,
and the items in the right are supposed to be the link addresses. When
it was switched from a day rotation to a timed rotation something is
keeping it from working as a link. Can anyone see why? Please let me
know, thanks, Amy
one that works by day just following and works correctly. <BODY
onload="changelink();"><a href="#" id="url"></a>

var arr = [
["Link name google web site"],["http://www.google.com"],
["two link"],["http://www.yahoo.com"]
];
Your code wants an array of arrays, make the above an array by removing
the inner brackets (untested, but if the rest works...):

var arr = [
["Link name google web site","http://www.google.com"],
["two link","http://www.yahoo.com"]
];

--
Rob

Nov 5 '06 #6
ASM
Michael Winter a écrit :
ASM wrote:
>Amy a écrit :
>>Can't you just tell me what you're trying to say, many of us don't have
instructors, I did a google search and I still don't know how to fix
it.

I assume you didn't read my second post in your previous thread, then?
Witch my previous thread ?
>var arr = [
[["Link name google web site"],["http://www.google.com"]],
[["two link"],["http://www.yahoo.com"]]
];

That wouldn't be right, either.
Ooops ! (but, tested, it worked)

var arr = [
["Link name google web site","http://www.google.com"],
["two link","http://www.yahoo.com"]
];

not tested as is
Nov 5 '06 #7
ASM wrote:

[snip]
Witch my previous thread ?
This is a continuation of the thread entitled, "Please, how to add a
random function to this?"[1]

[snip]

Mike
[1] Please, how to add a random function to this?
Amy <ri*******@aol.com>
Fri, 3 Nov 2006 13:29:13 UTC
<11*********************@b28g2000cwb.googlegroups. com>

<http://groups.google.co.uk/group/comp.lang.javascript/browse_thread/thread/906a73837c1de314/45f79ed9fa808ca3>
Nov 5 '06 #8
Amy
I had to leave the other thread because my code wasn't working.

Thank you very much ASM for helping me, very much appreciated. Anywhere
I can send you some stuff? Amy

Nov 6 '06 #9

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

Similar topics

5
by: Sorby | last post by:
Hi I've been coding in PHP for a little while now and was starting to feel pretty confident but then realise I need to understand regular expressions to solve a particular problem I've got ......
5
by: Subrahmanyam Arya | last post by:
Dear oracle gurus, I am unable to get past the error ORA-12154: TNS: could not resolve service name on my host when using hsodbc to talk to a remote mysql database. i got from the meta link all...
3
by: Dante | last post by:
Tonight I started writing a script that places a "Copy All" link before every PRE tag. The link would copy the code in the pre tag. I can't get this script to work. Can anyone help me? Here is my...
2
by: dinks | last post by:
Hi, I'm new to C++ and have been assigned a task which i dont completely understand. Any help would be greately appreciated. Here is the problem: The class "linkedListType" use the "assert"...
3
by: Dai Ba Wong | last post by:
Hi: Currently I am having a problem with my webpage. My page consist of two frames, one consist of input text field and the other contains link for different pop-up windows. The problem...
1
by: Koen | last post by:
Hi all, I created a little database to manage my e-books. The program will synchronize a table with the contents of a directory. Works great. Because I keep additional info (like keywords) to...
4
by: jereme.goblue | last post by:
The web page at http://www.rossowinspections.com/ has an issue with the left menu. The left menu has 7 links. One of the links doesn't work. Using Firefox 1.5 the Fees link isn't a clickable...
1
by: tccode97 | last post by:
Hi, I need an urgent help. I am developing a socket application in VC++ that uses asynchronous connnection. After doing search on google, I found the following link ...
9
by: Kernel Bling | last post by:
Hi Everyone, This Saturday the stage was set. The problem simply could not go on existing -- it had to be solved. Many hours, articles, compilations and frustrations later I still did not find...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.