Page 1 of 1
remove an item in drop down list after the form is submitted
Posted: Thu Sep 30, 2010 2:16 am
by mathieu
hey
I am using a php drop down list that is populated from a mysql database. The list is on a form and i need to be able remove an item from the list once it has been selected and submitted in the form. Once the item has beeen selected and submitted in the form it has to be deleted from the list.
Any ways i can do this?
thanks
Re: remove an item in drop down list after the form is submi
Posted: Thu Sep 30, 2010 6:24 am
by phpaverage
google is your best friend or you pay me and il help you

Re: remove an item in drop down list after the form is submi
Posted: Thu Sep 30, 2010 6:33 am
by DigitalMind
It depends on what exactly you want to do. If you want to remove the items just for the current session use something like $_SESSION['deleted_items][] and don't output the items which are in that array.
Re: remove an item in drop down list after the form is submi
Posted: Thu Sep 30, 2010 6:34 am
by DigitalMind
phpaverage wrote:google is your best friend or you pay me and il help you

Would you like to have a cup of poison?
Re: remove an item in drop down list after the form is submi
Posted: Thu Sep 30, 2010 10:00 am
by twinedev
If you have the drop down list on a form that does an AJAX call (ie, the form stays on the page when you submit it), you can use the following:
(assuming here that the function was passed
this as a parameter named
elem, otherwise you will need to set elem to be the select element first)
Code: Select all
elem.options[elem.selectedIndex] = null;
-Greg
PS. Digitalmind, I was very tempted to go copy his reply to his own questions here LOL