afrojojo Posted November 1, 2006 Share Posted November 1, 2006 Is there a way to remove a drop down field after the form is submitted? Example: This is a drop down form with 5 options: option 1 option 2 option 3 option 4 option 5 Someone chooses option 2 and submits the form. Now the forms drop down field contain these options: option 1 option 3 option 4 option 5 Please help, thanks. Link to comment https://forums.phpfreaks.com/topic/25864-drop-down-menu/ Share on other sites More sharing options...
thepip3r Posted November 1, 2006 Share Posted November 1, 2006 yes... use PHP to write out the SELECT portion of your form. BUT have it check to see if a $_POST['drop_down_box_name'] exists, and if it does, use a conditional to check to see if $_POST['drop_down_box_name'] is != to whatever the dropdown box element being writting by PHP. The logic here is that if it's been previously submitted, it'll be in the $_POST array. Then when the page is rewritten, if u echo out every <option> of the drop-down menu but check it to see if it equals the value in $_POST['drop_down_box_name'] and if it does, it leaves that part of the code blank, it will accomplish waht you're looking for. Link to comment https://forums.phpfreaks.com/topic/25864-drop-down-menu/#findComment-118109 Share on other sites More sharing options...
afrojojo Posted November 1, 2006 Author Share Posted November 1, 2006 Eh? Could you give me an example please? Link to comment https://forums.phpfreaks.com/topic/25864-drop-down-menu/#findComment-118110 Share on other sites More sharing options...
thepip3r Posted November 1, 2006 Share Posted November 1, 2006 [code=php:0] echo "<select name=\"fruits\">"if ($_POST['fruits']) { if ($_POST['fruits'] != 'apple') echo "<option>apple</option>"; if ($_POST['fruits'] != 'orange') echo "<option>oranges</option>"; if ($_POST['fruits'] != 'bannana') echo "<option>bannana</option>";} else {echo "<option>apple</option>";echo "<option>oranges</option>";echo "<option>bannana</option>";}echo "</select>";[/code]NOTE: This will only work for the MOST immediately selected item. If u want it to hold more than one item or more than one click, you'll have to add the information to a global array and then only list the items that don't exist in that array. Link to comment https://forums.phpfreaks.com/topic/25864-drop-down-menu/#findComment-118114 Share on other sites More sharing options...
afrojojo Posted November 2, 2006 Author Share Posted November 2, 2006 Well, thats not really going to work. I have a list. People choose something from that list in a drop down menu. Each thing on that list is an <option> in the drop down menu. When someone chooses that item on the list, its not available anymore. So when that user or anyone else goes back to that list, the option that was just submitted is not available in the drop down menu anymore. Same thing if another item is selected and so on... Link to comment https://forums.phpfreaks.com/topic/25864-drop-down-menu/#findComment-118268 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.