Jump to content

Recommended Posts

[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

[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;
	}

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.