gnawz Posted July 23, 2007 Share Posted July 23, 2007 Hi I have a drop down thus <form name = frmUtils method = POSTaction = ""> <select name = Do> <option>Add</option> <option>Delete</option> <option>Update</option> </select> </form> I want the form action to change based on the selection ie if selected Index is Add action = add.php if selected Index is Delete action = delete.php if selected Updateis Add action = update.php Somebody help Link to comment https://forums.phpfreaks.com/topic/61339-action-depending-on-drop-down/ Share on other sites More sharing options...
DeadEvil Posted July 23, 2007 Share Posted July 23, 2007 Note: The code is not tested be aware of that... <script type="text/javascript"> function do_action_page(form) { var select_form = ""; var select_form = form.select_action.value; if(select_form == ''){ alert('empty select'); } else { var select_form = form.frmUtils.action; } } </script> <select name="select_action" onchange="return do_action_page(this)"> <option value="add.php">add.php</option> <option value="delete.php">delete.php</option> <option value="update.php">update.php</option> </select> #this must be php file $content = ""; $content .= "<form name = 'frmUtils' method = 'POST' action="">"; $content .= "<select name = Do>"; $content .= "<option>Add</option>"; $content .= "<option>Delete</option>"; $content .= "<option>Update</option>"; $content .= "</select>"; $content .= "</form>"; echo $content; Link to comment https://forums.phpfreaks.com/topic/61339-action-depending-on-drop-down/#findComment-305228 Share on other sites More sharing options...
gnawz Posted July 23, 2007 Author Share Posted July 23, 2007 Thanks for your help. I'm trying it out but still troublesome I want to put my actions in a switch like $Action = $_GET ['Function'] switch($Action) { case 'add': add function; break; case 'update': update function; break; case 'delete': delete function; break; } Link to comment https://forums.phpfreaks.com/topic/61339-action-depending-on-drop-down/#findComment-305320 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.