PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
ridshack
Forum Commoner
Posts: 29 Joined: Wed Oct 11, 2006 10:34 pm
Post
by ridshack » Thu Nov 30, 2006 11:30 pm
Hi all Im trying to populate a dropdown from 0 to 10 by 0.25 s but cant figure out how. Thank you for any help.
Example:
.00
.25
.50
.75
1.00
1.25
And so on until 10
This is what I have worked up so far... It just displays four 00 and then a bunch of blank spaces.
Code: Select all
<SELECT NAME='ot' SIZE='1'>
<?php
settype( $o, 'double' );
for ($o = 0; $o <= 10; $o = $o + 25) {
echo "<option value='$quarters[$o]'";
if ($o == $TimeOutMinute) { echo " selected='selected'"; }
echo ">$quarters[$o]</option>";
} ?>
</SELECT>
Last edited by
ridshack on Sat Dec 02, 2006 12:09 am, edited 2 times in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Nov 30, 2006 11:38 pm
range() may be of interest.
ridshack
Forum Commoner
Posts: 29 Joined: Wed Oct 11, 2006 10:34 pm
Post
by ridshack » Fri Dec 01, 2006 11:37 pm
Thanks for your help. That did the trick.
Code: Select all
<?php
foreach (range(0, 10, .25) as $ot25) {
echo "<option value='$ot25'";
if ($ot25 == $ot) { echo "selected='selected'"; }
echo ">$ot25</option>";
}
?>