dflow Posted December 28, 2009 Share Posted December 28, 2009 i want on submit to go to different pages according to the CatID <?php $CatID=$_GET['CatID']; if (isset($CatID)) { } switch ($CatID) { case 1: echo '<form action="new-product-full-page-citycountry.php" method="get">'; break; case 2: echo '<form action="new-product-full-page-region.php" method="get">'; break; } ?> <table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="150"><select name="CatID" onChange="getState(this.value)"> <option value="0">Select Category</option> <?php do { ?> <option value="<?php echo $row_RsCategories['CategoryID']?>"><?php echo $row_RsCategories['CategoryName']?></option> <?php } while ($row_RsCategories = mysql_fetch_assoc($RsCategories)); $rows = mysql_num_rows($RsCategories); if($rows > 0) { mysql_data_seek($RsCategories, 0); $row_RsCategories = mysql_fetch_assoc($RsCategories); } ?> </select></td> </tr> <tr style=""> <td ><div id="statediv"><select name="state" > <option>Select Category First</option> </select></div></td> </tr> <tr style=""> <td ><div id="citydiv"><select name="city"> <option>Select Country First</option> </select></div></td> </tr> <tr> <td><label> <input type="submit" name="submit" id="submit" value="Submit"> </label></td> </tr> <tr> <td> </td> </tr> </table> </form> Link to comment https://forums.phpfreaks.com/topic/186511-switch-form-actions-not-working/ Share on other sites More sharing options...
Buddski Posted December 28, 2009 Share Posted December 28, 2009 <?php $form_action = "DEFAULT LOCATION"; if (isset($_GET['CatID'])) { switch ($CatID) { case 1: $form_action = "new-product-full-page-citycountry.php"; break; case 2: $form_action = "new-product-full-page-region.php"; break; } echo '<form action="'.$form_action.'" method="get"> ?> Link to comment https://forums.phpfreaks.com/topic/186511-switch-form-actions-not-working/#findComment-984951 Share on other sites More sharing options...
dflow Posted December 28, 2009 Author Share Posted December 28, 2009 <?php $form_action = "DEFAULT LOCATION"; if (isset($_GET['CatID'])) { switch ($CatID) { case 1: $form_action = "new-product-full-page-citycountry.php"; break; case 2: $form_action = "new-product-full-page-region.php"; break; } echo '<form action="'.$form_action.'" method="get"> ?> i get an "Parse error: syntax error, unexpected $end in" pointing to the end of the code(this is an included file) Link to comment https://forums.phpfreaks.com/topic/186511-switch-form-actions-not-working/#findComment-984982 Share on other sites More sharing options...
Buddski Posted December 28, 2009 Share Posted December 28, 2009 <?php $form_action = "DEFAULT LOCATION"; if (isset($_GET['CatID'])) { switch ($CatID) { case 1: $form_action = "new-product-full-page-citycountry.php"; break; case 2: $form_action = "new-product-full-page-region.php"; break; } } echo '<form action="'.$form_action.'" method="get"> ?> Sorry 'bout that.. Link to comment https://forums.phpfreaks.com/topic/186511-switch-form-actions-not-working/#findComment-984984 Share on other sites More sharing options...
dflow Posted January 7, 2010 Author Share Posted January 7, 2010 for some <?php $form_action = "DEFAULT LOCATION"; if (isset($_GET['CatID'])) { switch ($CatID) { case 1: $form_action = "new-product-full-page-citycountry.php"; break; case 2: $form_action = "new-product-full-page-region.php"; break; } } echo '<form action="'.$form_action.'" method="get"> ?> Sorry 'bout that.. for some reason your example only gets the default location i tried something different but the action value is not passed on when you press submit the first time??? {code] <?php $CatID=$_GET['CatID']; if (isset($CatID)) { } switch ($CatID) { case 1: $action='../region.php'; break; case 2: $action='../city.php'; break; } ?> <form action="<?php echo $action;?>" method="get"> [/code] Link to comment https://forums.phpfreaks.com/topic/186511-switch-form-actions-not-working/#findComment-990224 Share on other sites More sharing options...
dflow Posted January 10, 2010 Author Share Posted January 10, 2010 ok went client side as i should have <script type="text/javascript" language="javascript"> // form action URLS here, keyed to selected values var action = Object(); action['1'] = 'region.php'; action['2'] = 'city.php'; action['3'] = 'region.php'; function chkredir(oForm) { var oSelect = oForm.CatID; //get select oForm.action = action[oSelect[oSelect.selectedIndex].value]; //plug in selected value to action object return true; } function checkform(oForm) { //validation routines here return chkredir(oForm); } </script> <form onsubmit="return checkform(this)" method="GET"> Link to comment https://forums.phpfreaks.com/topic/186511-switch-form-actions-not-working/#findComment-992241 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.