Page 1 of 1

How do I populate numeric dropdowns?

Posted: Tue Jan 17, 2006 12:47 pm
by Wobbly

Code: Select all

<select name='dropdown' size='1'>
<option value='0'>0</option>
<option value='1'>1</option>
<option value='2'>2</option>
</select>
Hey guys,

I have several dropdowns that I need to populate with numbers from 1 to 50. Is there a quick way of doing this without having to write a separate option value for each one of them?

Thanks,
Nick

Posted: Tue Jan 17, 2006 1:18 pm
by foobar
No.

Posted: Tue Jan 17, 2006 1:23 pm
by Charles256
: smacks foobar promptly:
ignore him.

Code: Select all

<option value='0'>0</option>
<option value='1'>1</option>
<option value='2'>2</option>

Code: Select all

for($i=1;$i<51;$i++)
{
   echo "<option value='$i'>$i</option>";
}
that'll give you all the numbers from 1 to 50...next time at least google "looping in php" or something like that,at least try to search ;) either way,you're welcome.enjoy.

Posted: Tue Jan 17, 2006 1:58 pm
by Wobbly
Charles256 wrote: that'll give you all the numbers from 1 to 50...next time at least google "looping in php" or something like that,at least try to search ;) either way,you're welcome.enjoy.
Thanks Charles,

I actually did search; both here and elsewhere... Guess I didn't really know what I was searching for. Anyway, I appreciate your help.

Thanks again,
Nick

Posted: Tue Jan 17, 2006 3:36 pm
by foobar
Charles256 wrote:: smacks foobar promptly:
ignore him.
According to his own request:
Is there a quick way of doing this without having to write a separate option value for each one of them?
My answer was correct. You have to write out a separate option-tag for each option. :?

Posted: Tue Jan 17, 2006 3:42 pm
by Charles256
well..you don't write it out..the loop does..it's a technicallity..: revokes the slap : happy? :-D

Posted: Tue Jan 17, 2006 3:52 pm
by foobar
Charles256 wrote:: revokes the slap : happy? :-D
No way. I wanna a cookie! :lol: