random div weergeven

Status
Niet open voor verdere reacties.

phille125

Gebruiker
Lid geworden
3 aug 2009
Berichten
57
ik zou graag een paar div's random willen weergeven.
buiten mijn code werkt 't perfect en in de code niet. wat doe ik fout?

code buiten mijn html
HTML:
<head>
	<script language="javascript">
		function disp() {
			var r = Math.round(Math.random()*8)+1;
			document.getElementById('div'+r).style.display='block';
		}
	</script>
	<style type="text/css" >
		#div1{ background-color:#000000; width:400px;}
		#div2{ background-color:#ffffff; width:400px;}
		#div3{ background-color:#fff000; width:400px;}
		#div4{ background-color:#000fff; width:400px;}
		#div5{ background-color:#123456; width:400px;}
		#div6{ background-color:#006699; width:400px;}
		#div7{ background-color:#FF0000; width:400px;}
		#div8{ background-color:#FF00FF; width:400px;}
		#div9{ background-color:#009999; width:400px;}
	</style>
</head>
 
<body onload="disp()">
	<div id="div1" style="display:none;">Line Number One</div>
	<div id="div2" style="display:none;">Line Number Two</div>
	<div id="div3" style="display:none;">Line Number Three</div>
	<div id="div4" style="display:none;">Line Number Four</div>
	<div id="div5" style="display:none;">Line Number Five</div>
	<div id="div6" style="display:none;">Line Number Six</div>
	<div id="div7" style="display:none;">Line Number Seven</div>
	<div id="div8" style="display:none;">Line Number Eight</div>
	<div id="div9" style="display:none;">Line Number Nine</div>
</body>
</html>

code werkt niet
HTML:
<head>
    <script language="javascript">
		function disp() {
			var r = Math.round(Math.random()*8)+1;
			document.getElementById('div'+r).style.display='block';
		}
	</script>
    <style type="text/css">
<!--
.style1 {
	color: #042d89;
	font-weight: bold;
	font-size:20px;
}
-->
    </style>
</head>
<body>
	<div id="container">
  <div id="content">
          <div id="titel_2">Confirmed speakers</div>
            <div id="tekst_home2">
<!-- Jan Verheyen -->
                    <div id="div1" style="display:none;" class="section">
                		<div>
            				<p>
                        		<img src="Beelden/speakers/jan-verheyen_gr.jpg" alt="Jan Verheyen" />
                                <strong style="font-size:18px;">Jan VERHEYEN</strong><br />
                        Movie Director & Television Presenter
                            	<br /><br />
                        		<strong>Topic:</strong><br />
                        		<em>"What can we learn from the movie industry to make meetings more attractive?"</em><br /><br />
                        		Moviemakers have the same challenge as meeting planners: to keep their audience focussed and interested during several hours. How do they do that?<br /><br />
                        		<strong>About Jan Verheyen:</strong><br />
                        		Belgian movie director of many well-known films such as Team Spirit, Buitenspel, Dossier K en Zot van A. Besides making movies, Jan is very active on television as presenter of different talk shows. He is also the organiser of 'De Nacht van de Wansmaak', a movie festival with trash and cult films.
            				</p>
            			</div>
                        <!-- Len BRANSON -->
            		<div id="div2" style="display:none;" class="section">
                		<h3><a href="#two">Len BRANSON</a></h3>
                		<div>
            				<p>
                            	<img src="Beelden/speakers/Len-BRANSON.jpg" alt="Jan Verheyen" />
                        		Music Director Radio 1 NL,<br /> 
	                        	Author of Superwise Me!<br />
    	                    	<a href="http://www.superwiseme.com" target="_blank">www.superwiseme.com</a><br /><br />
        	                	<strong>Topic:</strong><br /><br />
            	            	<em>"Superwise me: How our thoughts influence the outcome of meetings"</em><br /><br />
                	        	Organising meetings means coping with stress and deadlines. Keeping a positive mind when things become hard can make the difference between a disaster and a success story. <br /><br />
                    	    	<strong>About Len Branson:</strong><br />
                        		Len's origin is Belgian but he is living in The Netherlands for 25 years now, where he is the music director of Radio 1.  He is the business partner of Roos Van Acker and the founder of the TMF awards. <br />
                        		In 2009, Len started a spiritual experiment in the mountains near Sevilla (Spain) in search of the answer where the biggest wisdom can be found: within everyone's self. He wrote these experiences down in a book that he calls to be the European answer on 'the Secret'. Soon also a documentary will be launched. Len is convinced that the state of mind we are in, has a direct influence on the results we get in business and in life.
                        	</p>
                		</div>
            		</div>
<!-- Leki - Karoline KAMOSI -->
                    <div id="div3" style="display:none;" class="section">
            			<h3><a href="#three">Leki - Karoline KAMOSI</a></h3>
                		<div>
            				<p>
                       		  <img src="Beelden/speakers/Leki.jpg" alt="Jan Verheyen" />
                              Singer<br />
                              <span style="font-size:9px;">Foto: © Wim Vandegenachte</span><br />
                           	  <a href="http://www.lekimusic.com/" target="_blank">www.lekimusic.com/</a><br />
                           	  <a href="http://www.lekimusic.com/" target="_blank">www.een.be/programmas/de-rode-loper/zussen-op-missie/</a><br /><br />
                            	<strong>Topic:</strong><br />
                            	<em>"How the meetings industry can support a better live in Congo"</em><br /><br />
                            	<strong>About Karoline Kamosi:</strong><br />
                            	Karolin was born in Kinshasa but grew up as a real Flemish girl. She is a successful hip-hop artist and the sister of Ya Kid K (Manuela), known from the world hit Pump up the Jam. Although Karonline's passion is music, music and music, she is taking on the project her father started in Congo, to build a hospital.
                            	Foto: © Wim Vandegenachte
            				</p>
            			</div>
            		</div>
<!-- Gerd CAMPAERT -->
                    <div id="div4" style="display:none;" class="section">
                		<h3><a href="#for">Gerd CAMPAERT</a></h3>
                		<div>
            				<p>
                            	<img src="Beelden/speakers/Gerd-CAMPAERT.jpg" alt="Jan Verheyen" />
                                Imago Consultant<br />
                        		<a href="http://www.gerdcampaert.be" target="_blank">www.gerdcampaert.be</a><br /><br />

                        		<strong>Topic:</strong><br />
                        		<em>"Dress for success - Colour and clothing technology for the meeting professional"</em><br /><br />
                        		<strong>About Gerd Campaert</strong><br />
                        		Gerd specialises in 'making people beautiful'. She is one of the first image consultants in Belgium, since 1987. Besides giving personalised advice, Gerd is very active in corporate environments, giving workshops to get the most out of business presence. She uses the CMB-system to typify a person. Based on that system, Gerd advises in colours and styles that would suit this person’s natural presence best. 
                        	</p>
                		</div>
            		</div>
<!-- Robert HERSEE, Michiel HESSELING & Wouter HESSELING -->
                    <div id="div5" style="display:none;" class="section">
                		<h3><a href="#eight">Robert HERSEE, Michiel HESSELING & Wouter HESSELING</a></h3>
                		<div>
            				<p>
                            	<img src="Beelden/speakers/Robert-Hersee.jpg" alt="Robert Hersee" />
                                <img src="Beelden/speakers/Michiel-Hesseling.jpg" alt="Michiel Hesseling" />
                                <img src="Beelden/speakers/Wouter-Hesseling.jpg" alt="Wouter Hesseling" />
                                Right brain thinkers and specialists in the ‘art of letting go’.<br />
                                <a href="http://www.moreballs.com" target="_blank">www.moreballs.com</a><br /><br />
                        		<strong>Topic:</strong><br />
                        		<em>"Enhance your right brain thinking to access new meeting solutionsl"</em><br /><br />
                        		<strong>About Robert Hersee</strong><br />
                        		Born in Tanzania with British roots, Robert studied industrial psychology. He was an artist, a musician, an illustrator, a developer, a translator, a project manager and a husband. Today he is co-director of Holland’s most unusual company: More Balls Than Most.<br /><br />
                                <strong>About Michiel Hesseling</strong><br />
                        		At the age of 20, Michiel impressed the world with his legendary duo The Flying Dutchmen, showing his unique gift to juggle balls, like no one else on the planet could. He refused several offers to work together with Cirque du Soleil as he preferred no to travel as much as before. Today, he is fully connected to More Balls, using a metaphor to explain boring but important business issues.<br /><br />
                                <strong>About Wouter Hesseling</strong><br />
                        		Wouter studied biology, but his real passion and talent is juggling. First he used oranges while helping with the crops, later with balls. Today he is living his dream while inspiring business people with his magical talent during corporate business theatre performances and shows.
                        	</p>
                		</div>
            		</div>
<!-- Ron NAT MUKHERJEE -->
                  <div id="div6" style="display:none;" class="section">
                		<h3><a href="#five">Ron NAT MUKHERJEE</a></h3>
                		<div>
            				<p>
                            	<img src="Beelden/speakers/Ron-Nat-Mukherjee.jpg" alt="Jan Verheyen" />
                                Webmedia Specialist<br />
                        		<a href="http://www.richcast.eu" target="_blank">www.richcast.eu</a><br />
                        		<a href="http://www.arjuna.be" target="_blank">www.arjuna.be</a><br /><br />

                        		<strong>Topic:</strong><br />
                        		<em>"Webcating: enlarging the meeting impact and post conference return."</em><br /><br />
                                Webcasting is a hot topic in times of cost cutting and return on investment of meetings. Clients demand more return on investment on their conferences than ever before. Yet how could webcasting be an added value for the delegates? Is it hard to do? Is it even necessary? Come and find out!<br /><br />
                        		<strong>About Ron Nat Mukherjee</strong><br />
                        		Building on 12 years of experience in the fields of communications and online video-production, Ron oversees and is responsible for delivering innovative yet reliable corporate and institutional rich media products and services.<br /><br />
                 		</div>
           		  </div>
<!-- Peggy RICHIE -->
                    <div id="div7" style="display:none;" class="section">
                		<h3><a href="#six">Peggy RICHIE</a></h3>
                		<div>
            				<p>
                            	<img src="Beelden/speakers/Peggy-Richie.jpg" alt="Jan Verheyen" />
                        		Professional Presenter, Trainer & Musician<br />
                        		<a href="http://www.on-stage-expertise.com" target="_blank">www.on-stage-expertise.com</a><br /><br />
                        		Peggy will be your host and interviewer on stage, during the Educational, together with Steve.<br /><br />
                        		<strong>About Peggy Richie</strong><br />
                        		Peggy feels on stage, like a fish feels in water. She has a long track record being a professional presenter and moderator for conferences and shows. But her first passion was singing, and still is.<br />
                        		Besides stepping herself on stage, Peggy is giving workshops in public speaking. She is a personal coach to many corporate and business personalities, helping them to improve their stage performance and speaking capacities.
                         	</p>
                		</div>
            		</div>
<!-- Steve DE WIT -->
                    <div id="div8" style="display:none;" class="section">
                		<h3><a href="#seven">Steve DE WIT</a></h3>
                		<div>
            				<p>
                        		<img src="Beelden/speakers/Steve-de-wit.jpg" alt="Jan Verheyen" />
                                Corporate Meeting Planner, Author & Trainer
                        		<a href="http://www.stevedewit.com" target="_blank">www.stevedewit.com</a><br />
                        		<a href="http://www.barranco.org" target="_blank">www.barranco.org</a><br /><br />
                        		In cooperation with Peggy, Steve will be your content guide on stage during the Educational.<br /><br />
                        		<strong>About Steve De Wit</strong><br />
                        		Steve started his own meeting planners agency, Barranco, in 1989. Over the past 21 years, he was organising meetings and conferences in 23 countries spread over the over the world.<br />
                        		In 2009, he wrote his passion and experience for conferences down in the book 'Secrets of Effective Meetings and Events'. Today, he is dividing his time between organising conferences and giving trainings and workshops in conference management, to meeting professionals all over Europe.
                        	</p>
                		</div>
            		</div>
            		</div>
            </div>
        </div>
    </div>
</body>
 
Hallo,

Je bent in ieder geval type="text/javascript" vergeten in je script tag.

Weet niet zeker of dit verplicht is, of enkel XHTML valid is, maar probeer dat eens.

dus <script type="text/javascript" language="javascript"> </script>

leuk bedacht trouwens, maar realiseer je wel dat als de gebruiker javascript uit heeft geschakeld, er geen enkel block gedisplayed zal worden. Dit zorgt voor de nodige verschuivingen in je webdesign. Misschien kun je beter met javascript de tekst van de div laten wijzigen, en er een standaard tekst in laten staan.
PHP lijkt mij hier trouwens geschikter voor, dan kun je op de server laten bepalen welke div er aan de gebruiker getoond wordt en maakt het niet uit of de gebruiker javascript heeft uitgeschakeld.
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan