Masamune212
11-19-2005, 05:50 PM
Okay say I want to make like 3 drop down menus. I want the selection they are at first to be randomly selected. Is there anyway to do this?
|
Click to See Complete Forum and Search --> : Randomization Masamune212 11-19-2005, 05:50 PM Okay say I want to make like 3 drop down menus. I want the selection they are at first to be randomly selected. Is there anyway to do this? The Little Guy 11-19-2005, 08:06 PM JavaScript BonRouge 11-20-2005, 12:23 AM You could do it with php. Here's an example (http://bonrouge.com/test/randselect.php): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Random selected option</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style type="text/css"> body { margin:0; padding:0; background-color:#fff; } </style> </head> <body> <p> <select> <?php $option=array ("one","two","three"); $rand=rand(0,count($option)-1); $i=0; while ($i<count($option)) { echo " <option value=\"$option[$i]\"".(($i==$rand)? ' selected="selected"':'').">$option[$i]</option>"; $i++; } ?> </select> </p> </body> </html> Masamune212 11-22-2005, 10:20 PM Where do I add my content? BonRouge 11-23-2005, 12:37 AM Where do I add my content? I'm sorry? Where do you add your content??? Erm... between the body tags? :confused: webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |