Author |
Message |
Ktomislav
|
Posted: Sat Jan 09, 2010 7:51 pm Post subject: Populating select tag |
|
|
Can you tell me how to populate select tag through for loop?
For example how to add every number form 1 to 10 to select tag (without brute forcing)?
Thanks |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Ktomislav
|
Posted: Mon Jan 11, 2010 8:13 pm Post subject: Re: Populating select tag |
|
|
Well, I'm sorry for double post, but come on guys help me please. |
|
|
|
|
|
Zren
|
Posted: Mon Jan 11, 2010 8:17 pm Post subject: RE:Populating select tag |
|
|
code: |
<select>
<?php
for ($i=1;$i<=10;$i++) {
?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php
}
?>
</select>
|
Not generally a PHP/HTML forum but i know some stuff. |
|
|
|
|
|
Ktomislav
|
Posted: Mon Jan 11, 2010 8:20 pm Post subject: Re: Populating select tag |
|
|
Thank you very much!
edit: Nice trick! |
|
|
|
|
|
Zren
|
Posted: Mon Jan 11, 2010 8:30 pm Post subject: RE:Populating select tag |
|
|
No prob. You could do it all in one echo, but it requires a monstrous amount of escape characters.
Thus with PHP, starting and endling blocks don't actually end the script and you can break stuff up like this. It's pretty awesome. |
|
|
|
|
|
Ktomislav
|
Posted: Mon Jan 11, 2010 8:35 pm Post subject: Re: Populating select tag |
|
|
I figured it out I know it can be done in one echo, but thanks anyway.
And yes it is pretty awsome because it is so simple, but kinda so powerful. |
|
|
|
|
|
|