HTML Arggggggggggggggghh

Discussion topics, Linux related - not requests for help

Moderators: ChrisThornett, LXF moderators

HTML Arggggggggggggggghh

Postby shifty_ben » Mon Nov 07, 2005 5:31 pm

Hi all,
im in the process of building a website for the company I work for, they wnat it HTML and javascript only. Problem is they also wnat somethign else that I cant seem to do. To put ti basically in the top corner of the page is an image, simple enough so far, but they want the image to be randomly selected from within a set directory, I guess because they want to push all ur wonderufl offers, I though I could probably do this with Javascript but it seems my skills in this area have died a bit of a death. Anyone have any ideas of a good way to do this. If I was hosting on my machine I would be lazy and set up a cron job that changes a random image to a set filename every 15 minutes or whatever but as they are planning to host it on their IIS server I guess that option is out of the window. Any ideas would be greatly appreciated
User avatar
shifty_ben
LXF regular
 
Posts: 1292
Joined: Tue Oct 04, 2005 9:56 am
Location: Ipswich

RE: HTML Arggggggggggggggghh

Postby Lejon » Mon Nov 07, 2005 6:57 pm

Well as I don't work for that company, I would give them the finger :D
I am the one you thought I was! Just not the way, you expected...
User avatar
Lejon
LXF regular
 
Posts: 150
Joined: Wed Oct 19, 2005 7:24 pm
Location: Sweden

RE: HTML Arggggggggggggggghh

Postby Lejon » Mon Nov 07, 2005 6:59 pm

Point out to your compay, that if you use JavaScript, the user can simply turn it off and skip that shit.
While if you use PHP you can do Server Side Includes :)
I am the one you thought I was! Just not the way, you expected...
User avatar
Lejon
LXF regular
 
Posts: 150
Joined: Wed Oct 19, 2005 7:24 pm
Location: Sweden

Postby M0PHP » Mon Nov 07, 2005 9:20 pm

But if it's plain IIS, you can use ASP which is built in. I've used loads of ASP for active directory stuff but this should do for some random image:

Code: Select all
<%
dim arr_images, l, u, rs, rv, ri

'
' put your image filenames in this array
'
arr_images = array("image1.jpg","image2.jpg","image12.png")

l = 0
u = UBound(arr_images)
Randomize()
rs = u - l + 1
rv = rs * Rnd()
rv = rv + l
ri = Int(rv)
Response.Write "<img src="""&arr_images(ri)&""" alt="""" />"
%>


Hope it helps.
User avatar
M0PHP
LXF regular
 
Posts: 737
Joined: Wed Apr 06, 2005 7:40 am
Location: Bishop Auckland, County Durham, UK

Postby crispibits » Mon Nov 07, 2005 9:48 pm

If they really want it in javascript you could do this:
Code: Select all
<script language="JavaScript">
// Assumes images are called 1.jpg, 2.jpg...n.jpg
var numberOfImages = 9; //Insert number of images here
var text = '<img src="./graphics/'; //Alter to path containing images
text += (Math.floor(Math.random()*numberOfImages) + 1);
text += '.jpg"/>';
document.write(text);
</script>
I'm not a spammer - honest!
User avatar
crispibits
LXF regular
 
Posts: 201
Joined: Thu Jun 30, 2005 12:33 pm
Location: Bath

Postby crispibits » Mon Nov 07, 2005 9:55 pm

Or, if you'd rather name your images nicely:
Code: Select all
var images = ["image1.jpg","secondImage.jpg","Fish.jpg"];
var text = '<img src="./graphics/'; //Alter to path containing images
text += images[Math.floor(Math.random()*images.length)];
text += '"/>';
document.write(text);
I'm not a spammer - honest!
User avatar
crispibits
LXF regular
 
Posts: 201
Joined: Thu Jun 30, 2005 12:33 pm
Location: Bath

Postby shifty_ben » Mon Nov 07, 2005 9:56 pm

kool thanks for the help guys, I would quite like to give them the finger on this issue, but I guess they do pay my wages, I think the Javascript idea will probably have to do the job as sadly the Computer People in the company seem to be quite techno scared, and I cant be arsed to explain tot hem the benfits of ASP, should never have told them I run Linux, the reaction is kinda similar to many ISP support lines when you say you run Linux, a moment of silence and then sorry we cant help :?
User avatar
shifty_ben
LXF regular
 
Posts: 1292
Joined: Tue Oct 04, 2005 9:56 am
Location: Ipswich

Postby M0PHP » Mon Nov 07, 2005 10:00 pm

The best option is ASP as the client can't disable it - demonstrate how easy it is to disable JS and lose their image - how much is that worth (to them)?
User avatar
M0PHP
LXF regular
 
Posts: 737
Joined: Wed Apr 06, 2005 7:40 am
Location: Bishop Auckland, County Durham, UK

Postby shifty_ben » Mon Nov 07, 2005 10:13 pm

Very true, problem is that the website was my idea to develop a greater customer base for our branch, and the powers that be within the company frown down upon the idea a bit, its a sore point because their official website has only been running for a short while after having quite a few problems, so I kinda have to stick to their rules a bit, I am planning on suggesting that they point the subdomain that we are going to use at my Webserver, (for update efficiency obviously) the benefit of course being I can use PHP :D Before I do that though i need to build one that he can approve. I think part of their original issue with me hosting is down to the good old assumption that Linux is free, and free software contains a lot of spyware :shock: I can understand them not wanting to undermine their existing customer base in such a way but as I have and am patiently explaining Linux is nto freeare, it is open source. At best they will let me host it at worst they will shut the project down but a t least I will be free to develop websites to my own specifications.
User avatar
shifty_ben
LXF regular
 
Posts: 1292
Joined: Tue Oct 04, 2005 9:56 am
Location: Ipswich

Postby ollie » Mon Nov 07, 2005 11:17 pm

It is easy to this in PHP - it is one of the things I teach in web design. This is only a small number of images but it is easy to expand. See page 46 on my lesson notes (1.3 MB PDF):

PDF Lesson Notes

Hope this helps :wink:

Sorry, forgot the url tags = wiiiiiiiiiide page
User avatar
ollie
Moderator
 
Posts: 2749
Joined: Mon Jul 25, 2005 11:26 am
Location: Bathurst NSW Australia

Postby shifty_ben » Mon Nov 07, 2005 11:29 pm

don't worry about forgetting the tags, I always save PDFs to disk and open seperately anyway. It just seems to make life easier if I decide I need 2 reread a document. Course it does then mean that every week or so I need 2 go through any ive downloaded and decide what Im likely to need again lol Cheers for the help guys
User avatar
shifty_ben
LXF regular
 
Posts: 1292
Joined: Tue Oct 04, 2005 9:56 am
Location: Ipswich


Return to Discussion

Who is online

Users browsing this forum: No registered users and 0 guests