Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HTML Arggggggggggggggghh

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
shifty_ben
LXF regular


Joined: Tue Oct 04, 2005 10:56 am
Posts: 1292
Location: Ipswich

PostPosted: Mon Nov 07, 2005 5:31 pm    Post subject: HTML Arggggggggggggggghh Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Lejon
LXF regular


Joined: Wed Oct 19, 2005 8:24 pm
Posts: 150
Location: Sweden

PostPosted: Mon Nov 07, 2005 6:57 pm    Post subject: RE: HTML Arggggggggggggggghh Reply with quote

Well as I don't work for that company, I would give them the finger Very Happy
_________________
I am the one you thought I was! Just not the way, you expected...
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Lejon
LXF regular


Joined: Wed Oct 19, 2005 8:24 pm
Posts: 150
Location: Sweden

PostPosted: Mon Nov 07, 2005 6:59 pm    Post subject: RE: HTML Arggggggggggggggghh Reply with quote

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 Smile
_________________
I am the one you thought I was! Just not the way, you expected...
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
M0PHP
LXF regular


Joined: Wed Apr 06, 2005 8:40 am
Posts: 737
Location: Bishop Auckland, County Durham, UK

PostPosted: Mon Nov 07, 2005 9:20 pm    Post subject: Reply with quote

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:

<%
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.
Back to top
View user's profile Send private message Visit poster's website
crispibits
LXF regular


Joined: Thu Jun 30, 2005 1:33 pm
Posts: 201
Location: Bath

PostPosted: Mon Nov 07, 2005 9:48 pm    Post subject: Reply with quote

If they really want it in javascript you could do this:
Code:

<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!
Back to top
View user's profile Send private message
crispibits
LXF regular


Joined: Thu Jun 30, 2005 1:33 pm
Posts: 201
Location: Bath

PostPosted: Mon Nov 07, 2005 9:55 pm    Post subject: Reply with quote

Or, if you'd rather name your images nicely:
Code:

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!
Back to top
View user's profile Send private message
shifty_ben
LXF regular


Joined: Tue Oct 04, 2005 10:56 am
Posts: 1292
Location: Ipswich

PostPosted: Mon Nov 07, 2005 9:56 pm    Post subject: Reply with quote

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 Confused
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
M0PHP
LXF regular


Joined: Wed Apr 06, 2005 8:40 am
Posts: 737
Location: Bishop Auckland, County Durham, UK

PostPosted: Mon Nov 07, 2005 10:00 pm    Post subject: Reply with quote

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)?
Back to top
View user's profile Send private message Visit poster's website
shifty_ben
LXF regular


Joined: Tue Oct 04, 2005 10:56 am
Posts: 1292
Location: Ipswich

PostPosted: Mon Nov 07, 2005 10:13 pm    Post subject: Reply with quote

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 Very Happy 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 Shocked 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.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
ollie
Moderator


Joined: Mon Jul 25, 2005 12:26 pm
Posts: 2749
Location: Bathurst NSW Australia

PostPosted: Mon Nov 07, 2005 11:17 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
shifty_ben
LXF regular


Joined: Tue Oct 04, 2005 10:56 am
Posts: 1292
Location: Ipswich

PostPosted: Mon Nov 07, 2005 11:29 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast