angelsRock Posted September 9, 2007 Share Posted September 9, 2007 [code][code=php:0]<select size="1" name="package"> <option value="50" <?php if(isset($_POST[package])) $_POST[$A]; ?> selected>Premium Package RM50 (with RMXX talktime) </option> <option value="75" <?php if(isset($_POST[package])) $_POST[$B]; ?> >Premium Package RM75 (with RMXX talktime)</option> </select> <input type="submit" name="submitform" value="Upload" > <?php if(isset($_POST[submitform])) { $package=$_POST[package]; switch ($package) { case "50": $A="selected"; break; case "75": $B="selected"; break; } Quote Link to comment https://forums.phpfreaks.com/topic/68564-why-can-maintain-the-value/ Share on other sites More sharing options...
angelsRock Posted September 9, 2007 Author Share Posted September 9, 2007 [code][code=php:0]<select size="1" name="package"> <option value="50" <?php $A ?> >Premium Package RM50 (with RMXX talktime) </option> <option value="75" <?php $B ?> >Premium Package RM75 (with RMXX talktime)</option> </select> <input type="submit" name="submitform" value="Upload" > <?php if(isset($_POST[submitform])) { $package=$_POST[package]; switch ($package) { case "50": $A="selected"; break; case "75": $B="selected"; break; } Quote Link to comment https://forums.phpfreaks.com/topic/68564-why-can-maintain-the-value/#findComment-344655 Share on other sites More sharing options...
wildteen88 Posted September 9, 2007 Share Posted September 9, 2007 Your code is not correct. Try: <form action="#" method="post"> Package: <select size="1" name="package"> <?php $A = $B = null; if(isset($_POST['submit'])) { switch ($_POST['package']) { case '50': $A = ' selected="selected"'; break; case '75': $B = ' selected="selected"'; break; } } ?> <option value="50"<?php echo $A; ?>>Premium Package RM50 (with RMXX talktime)</option> <option value="75"<?php echo $B; ?>>Premium Package RM75 (with RMXX talktime)</option> </select><br /> <input type="submit" name="submit" value="Submit" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/68564-why-can-maintain-the-value/#findComment-344668 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.