I'm trying to write some simple Javascript to randomly change the picture on the main page every time the page is loaded. It sounds simple enough, but it's not working. I wasn't that great at Javascript when I was still taking the web publishing class, and I've had five months to forget everything I learned. Can someone give me a hand? Thanks.
Posts: 9945 | Registered: Sep 2002
| IP: Logged |
posted
Jon, why are you doing this in JavaScript? If you have server-side scripting capabilities, this is trivial. I don't know how a specific method in JavaScript, though.
If you must use JavaScript, check out some sites with image rollovers. That will show you how to change the image being displayed by an img tag, which should get you most of the way there.
Posts: 26071 | Registered: Oct 2003
| IP: Logged |
posted
OK. If no one else gives you a solution here or at GC, I'll try to find something later when I get back from school.
If your server supports PHP as is, I may post a solution in PHP. If you would have to reconfigure, I'll look for a pure JS solution.
Posts: 26071 | Registered: Oct 2003
| IP: Logged |
posted
My host supports PHP. I've done a little searching, and I think I've found some scripts that would work. I'll try them out when I get home and let you know if I need any more help. Thanks, Dag.
Posts: 9945 | Registered: Sep 2002
| IP: Logged |
<img id="main_img" src="blank.png" alt="The main image">
</body> </html>
You do, of course, have to manually modify the list of images, or even generate that list using php if you want.
Posts: 1810 | Registered: Jan 1999
| IP: Logged |
quote:It's actually not so bad to do this in javascript rather than php. Here's an example:
I know. But I can do it in PHP without looking it up. Or as Jon Boy almost said, "I'd do it in PHP because I don't know JavaScript."
Posts: 26071 | Registered: Oct 2003
| IP: Logged |
*sigh* Maybe web design is not my calling in life. Or maybe I just should've taken a few more classes in it while I was still in school.
Posts: 9945 | Registered: Sep 2002
| IP: Logged |