gnawz Posted July 26, 2007 Share Posted July 26, 2007 these are my files reports.php $Report = $_GET['report']; switch ($Report) { case 'add' : addfunction(); break; case 'delete' : deletefunction(); break; case 'update' : updatefunction(); break; } the other file with my select... checkrpt.php <form name="frmUtils" method="post" action=""> <select name="Do" id ="Do"onChange="SwapReport();"> <option value="0">Select view</option> <option value="1">Add</option> <option value="2">Update</option> <option value="2">Delete</option> </select> </form> <script type="text/javascript"> function SwapReport() { if (document.frmUtils.Do.selectedIndex == 1) { document.frmUtils.action = "reports.php?report=add"; } else if (document.frmUtils.Do.selectedIndex == 2) { document.frmUtils.action = "reports.php?report=update"; } else (document.frmUtils.Do.selectedIndex == 3) { document.frmUtils.action = "reports.php?report=delete"; } } </script> Help from here. It is not working yet. Link to comment https://forums.phpfreaks.com/topic/61821-action-depending-on-dropdwon-selection/ Share on other sites More sharing options...
DeadEvil Posted July 26, 2007 Share Posted July 26, 2007 Check this out.. <? $Report = $_GET['report']; switch ($Report){ case 'add' : addfunction(); break; case 'delete' : deletefunction(); break; case 'update' : updatefunction(); break; } ?> the other file with my select... checkrpt.php <form name="frmUtils" method="post" action=""> <select name="Do" id ="Do"onChange="SwapReport();"> <option value="0">Select view</option> <option value="1">Add</option> <option value="2">Update</option> <option value="2">Delete</option> </select> </form> <script type="text/javascript"> function SwapReport(){ if (document.frmUtils.Do.selectedIndex == 1){ document.frmUtils.action = "reports.php?report=add"; } else if (document.frmUtils.Do.selectedIndex == 2){ document.frmUtils.action = "reports.php?report=update"; } else if(document.frmUtils.Do.selectedIndex == 3){ document.frmUtils.action = "reports.php?report=delete"; } else{ document.frmUtils.action = "reports.php?report=nofunction"; } } </script> Link to comment https://forums.phpfreaks.com/topic/61821-action-depending-on-dropdwon-selection/#findComment-307843 Share on other sites More sharing options...
vbnullchar Posted July 26, 2007 Share Posted July 26, 2007 try this small code <?php <form name="frmUtils" method="post" action=""> <select name="Do" id ="Do" onChange="SwapReport(this.value)"> <option value="reports.php?report=view">Select view</option> <option value="reports.php?report=add">Add</option> <option value="reports.php?report=upd">Update</option> <option value="reports.php?report=del">Delete</option> </select> </form> <script type="text/javascript"> function SwapReport(page){ location.href=page; } </script> ?> Link to comment https://forums.phpfreaks.com/topic/61821-action-depending-on-dropdwon-selection/#findComment-307846 Share on other sites More sharing options...
gnawz Posted July 26, 2007 Author Share Posted July 26, 2007 Thanks alot. It works!!!! Link to comment https://forums.phpfreaks.com/topic/61821-action-depending-on-dropdwon-selection/#findComment-308158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.