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 Quote Link to comment 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; Quote Link to comment 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; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.