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; } 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; } 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> 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
Archived
This topic is now archived and is closed to further replies.