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

create a variable link

Hi,

I must begin to say that I'm rather new in wtiting and using JavaScript. Now
I want to use JavaScript in a HTML-page. On the homepage is a link. Every
time the homepage is displayed the link must point to another target. I want
to realize this by having a lot of differet targetpages. The names of these
pages are p1001.htm until p<nnnn>.htm. At this moment the last is p1153.htm,
but the amount is increasing every day.
I have a file named "counter.txt" which contains one line with the string of
the last targetpage, at his moment "1153".

My idea is to have a JavaScript which:
1. reads the file counter.txt to determine the last available page
2. then takes at random one number between 1001 and 1153,
3. sets the HREF-link to page p<random>.htm.

I know it must be possible in JavaScript, but can anyone help me?

Thanks,

Susan
Jul 23 '05 #1
1 1316
asd987 wrote:
Hi,

I must begin to say that I'm rather new in wtiting and using JavaScript. Now
I want to use JavaScript in a HTML-page. On the homepage is a link. Every
time the homepage is displayed the link must point to another target. I want
to realize this by having a lot of differet targetpages. The names of these
pages are p1001.htm until p<nnnn>.htm. At this moment the last is p1153.htm,
but the amount is increasing every day.
I have a file named "counter.txt" which contains one line with the string of
the last targetpage, at his moment "1153".

My idea is to have a JavaScript which:
1. reads the file counter.txt to determine the last available page
2. then takes at random one number between 1001 and 1153,
3. sets the HREF-link to page p<random>.htm.

I know it must be possible in JavaScript, but can anyone help me?

Thanks,

Susan

Use an SSI to include "counter.txt", format it something like the
following:

<p id="whatever" style="display:none">[number here]</p>
<script type="text/JavaScript">
var base=isNaN(document.getElementById("whatever").inn erHTML)?""
:+(document.getElementById("whatever").innerHTML);
if(base){
document.write("<a href="+
(1001 + Math.floor (Math.random() * (base-1001)) )+
".html>click</a>")
}
</script>

Not tested.
Mick

Jul 23 '05 #2

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

Similar topics

6
by: Hansan | last post by:
Hi all. I am working on a webpage where I use python and html. When I want to send one variable to a new script/page I use the following code: 0) print '''<input type=hidden name="eventid"...
13
by: middletree | last post by:
I have a menu that I use on my Intranet app, and while I did try to replace it recently, I ended up going back to it. It's built entirely with javascript, and works great. However, there are...
7
by: olga | last post by:
Hi, On my site, i want to pass a javascript variable to php. I know that this needs to done in a link or in a post. I want to know if there is a way i can do it with an html link. I should...
3
by: Dr. Oz | last post by:
Hi, I am trying to read in a query string from one page and build a link to another page based on the query string. Here's the code I am using to read in the query string: <script...
10
by: Clay_Culver | last post by:
I have heard that it is possible to use classes + template magic to make standalone functions (or maybe just a functor which acts like a function) which can accept variable length arguments without...
4
by: Melissa | last post by:
I have a frontend file named CustomerApp and backend file named CustomerData. CustomerApp is at C:\Customer Database and CustomerData is at S:\Customer Database. Could someone help me with the code...
2
by: mikeoley | last post by:
Ok I have a Javascript slideshow working. Every image is linked to a another page in the site. Problem is...The link wont refresh to the next link once the second images rollovers in the slideshow....
6
by: Vyoma | last post by:
This is quite a bit of problem I am facing, and I cannot point exactly where I am going wrong. I have been lurking around at several forums with regard to login and user authentication scripts and...
16
by: John | last post by:
Does the length of my C variable names have any affect, performance-wise, on my final executable program? I mean, once compiled, etc., is there any difference between these two: number = 3; n =...
4
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
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.