FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » populating a list box problem
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: populating a list box problem [message #171102 is a reply to message #171099] Fri, 24 December 2010 19:31 Go to previous messageGo to previous message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma:
Senior Member
On Fri, 24 Dec 2010 14:25:27 -0500, Jerry Stuckle wrote:

> On 12/24/2010 2:09 PM, richard wrote:
>> rather than having a god awful long mess of "options" in the code, I would
>> like to populate the listbox by using php.
>>
>> One short code I found winds up with an error.
>>
>> Basically what I want is a simple array that holds a list of names.
>> A very long list. Over 500.
>> Actually, there will be 5 listboxes, with 100 to each box.
>>
>> The idea being, that when a name is clicked on, which resides in one
>> division, the corresponding information will show up beside it in another
>> division.
>>
>> Anyone have a site I can look at for help?
>> Googling just brings up tons of forums and sites that really don't discuss
>> what I need.
>>
>>
>
> The populating of a listbox is pretty easy - just loop through the array
> and echo the appropriate data, i.e.
>
> foreach ($myArray as $myItem)
> echo "<option value='$myItem'>$myItem</option>\n";
>
> Of course, if you have a unique identifier for each item, that would go
> in the value field instead of the item itself - but it gets the point
> across.
>
> If you want to display something based on the selection, you'll need a
> client side language such as javascript; the best way to do it would be
> to use AJAX to fetch the data from the server. See comp.lang.javascript
> for more information on javascript and AJAX.

thanks jerry. your approach seems rather straightforward enough even for me
to understand. I hope.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: New start-up seeking a programmer (vesting only!)
Next Topic: My first PHP Script...
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 14:31:22 GMT 2024

Total time taken to generate the page: 0.05462 seconds