Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="home-slogan">
- <?php
- $filename = "testimonials/testimonial.txt"; #specify file
- $file = fopen($filename, "r"); #open file
- $numLines = count(file($filename)); #count number of lines
- $lines = file($filename); #read lines into array
- $randomTestimonial = rand(0,$numLines); #generate random number
- ?>
- <h1 id="heading" align="center">"<?php echo $lines[$randomTestimonial];?>"</h1>
- <button type="button" id="next">Next Testimonial</button>
- <script>
- var randomTestimonial = <?php echo $lines[$randomTestimonial];?>;
- $("#next").click(function(){
- $("#heading").replaceWith(randomTestimonial);
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement