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
remove an item in drop down list after the form is submitted
Moderator: General Moderators
-
phpaverage
- Forum Newbie
- Posts: 5
- Joined: Thu Sep 30, 2010 3:55 am
Re: remove an item in drop down list after the form is submi
google is your best friend or you pay me and il help you 
- DigitalMind
- Forum Contributor
- Posts: 152
- Joined: Mon Sep 27, 2010 2:27 am
- Location: Ukraine, Kharkov
Re: remove an item in drop down list after the form is submi
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.
- DigitalMind
- Forum Contributor
- Posts: 152
- Joined: Mon Sep 27, 2010 2:27 am
- Location: Ukraine, Kharkov
Re: remove an item in drop down list after the form is submi
Would you like to have a cup of poison?phpaverage wrote: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
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)
-Greg
PS. Digitalmind, I was very tempted to go copy his reply to his own questions here LOL
(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; PS. Digitalmind, I was very tempted to go copy his reply to his own questions here LOL