list box with items for deletion passed from php array

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

 I want to display a list box that contains the elements from an array
(queried from database). There is a button next to the list box to
delete item(s) in the list box (and the same item(s) would be deleted
from database as well). It seems to me the functions for populating
and deleting items in the list box can be accomplished with
javascript. Could someone show me the best way to do this (not just
populating the list box but also for deleting the items afterwards)?
For starter, is dynamically 'echoing' the elements into a javascript
array (inside the <script language=javascript> tag) the right way to
populate the list box? TIA.

Re: list box with items for deletion passed from php array wrote:
Quoted text here. Click to load it

This is a PHP newsgroup, not a Javascript newsgroup.  Get your
javascript working first.  Then build it with the PHP.

But you won't be able to delete the items from the database with
javascript.  You'll need to submit the request to the server; this can
be done with javascript, either refreshing the page or through AJAX, but
you'll again need to get your javascript working, first.

Alternatively, you don't even need javascript; you can just submit the
items to be deleted to your PHP script (using a multi-select list box),
delete the items and return the page with the new list.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: list box with items for deletion passed from php array

Quoted text here. Click to load it

Thanks. I guess if the html listbox itself is created dynamically, no
javascript is needed (to pass/manipulate the array values around
between php and javascript). One can just submit the form and delete
values from the database based on the returned listbox's selected

Happy Holidays!

Site Timeline