Register FAQ/Rules Forum Spy Search Today's Posts Mark Forums Read

Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate.

 
Go Back   Mac Forums > Special Interests > Web Design and Development
TouchArcade.com - iPhone Game Reviews and News

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 14, 2009, 01:31 PM   #1
aaronw1986
macrumors 68020
 
Join Date: Oct 2006
dynamic text on main page

Hi all. I tried searching, but had trouble finding something relevant. How would I go about having different quotations (4-5) rotate which one is displayed on the main page of a site when it is loaded. The lower the language the better, is this possible with HTML/CSS? Any help would be greatly appreciated.
__________________
Mac Pro 8 core 2.8Ghz, 8800GT, 8GB RAM, 1.3TB
MBP 15" 2.4Ghz Glossy:4GB RAM,160GB 7200RPM HDD
Nikon D90: 70-300mm VR, 18-105mm VR, 50mm 1.8
aaronw1986 is offline   Reply With Quote
Old Jul 14, 2009, 02:42 PM   #2
BertyBoy
macrumors regular
 
Join Date: Feb 2009
PHP out of the question ? or JavaScript ?

You could store the key of the last quotation displayed to the user in their cookie, or session details, and modify it every time they load the page.
BertyBoy is offline   Reply With Quote
Old Jul 14, 2009, 02:43 PM   #3
Darth.Titan
macrumors 65816
 
Darth.Titan's Avatar
 
Join Date: Oct 2007
It's going to require some javascript at the very least.

Try these links.
Darth.Titan is offline   Reply With Quote
Old Jul 14, 2009, 02:52 PM   #4
angelwatt
macrumors 601
 
Join Date: Aug 2005
Location: Ohio
Can't be done with HTML/CSS alone as they are not dynamic. You could use JavaScript or PHP. JavaScript is the lower of the levels, but requiring it will mean visitors who have JavaScript disabled (like me) won't see the quote, unless you have a default one in place. PHP would be seen by everyone though.

Here's the quick and dirty though in JavaScript. The same idea can be used in PHP if you want.

PHP Code:
var quotes = [
  
"Hesitation kills!",
  
"One is the loneliest number.",
  
"With much money, comes great sadness."
];
var 
quote Math.floor(quotes.length Math.random());

function 
LoadQuote() {
  
document.getElementById('quote').innerHTML quotes[quote];
}
window.onload LoadQuote
__________________
MRoogle can find your answers!
Words on the Wall
angelwatt is offline   Reply With Quote

Reply

Mac Forums > Special Interests > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:26 PM.

Mac News | Mac Rumors | iPhone Game Reviews | iPhone Apps

Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 2002-2010, MacRumors.com, LLC