Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Rotate through divs

Featured Replies

Hi,

 

Got an information box on a site. Its all in one div, need something so that I can create, say 5 or 6 divs, and the page picks one at random every-time it loads, and displays this one. So different divs show when you go to the site on different occasions.

 

Man thanks,

 

Jonathan Padhiar

Hi,

 

Got an information box on a site. Its all in one div, need something so that I can create, say 5 or 6 divs, and the page picks one at random every-time it loads, and displays this one. So different divs show when you go to the site on different occasions.

 

Man thanks,

 

Jonathan Padhiar

 

Maybe consider using rand() php function and CSS for display:none.. just a thought

Building on what's a;ready been said.

 

you could do something like

 

<div id="my_div<?php echo rand(1,5); ?>">
 <p>Here is content</p>
</div>

 

EDIT: disreguard that as it will only change div's style!.... wake up Dave..

 

You could put the content in includes and randomly choose one.

 

<?php

$rn = rand(1,5);

include('content'.$rn.'.inc.php');

?>

Based on the suggestions above...

 

If you have all the divs on the page is to initially set their CSS to display:none;

Each div would have to have a class such as content1, content2 etc

In your page header, you could have a style declaration as follows:

<style type="text/css">
content<?php echo rand(1,5); ?> {
 display:block;
}
</style>

 

That will make a random block visible, and the others remain hidden.

 

Though I prefer the idea of using includes, I'd do it that way myself.

I used to have a CGI script that would work too, but I can't seem to find it.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.