Jump to content

[SOLVED] Can any one help me in “ListBox”.


oceans

Recommended Posts

Sorry Benjaminbeazy,

 

Can you guide me little more, please.

 

you are wanting a dropdown menu to have a 'pre-selected' feature to display to the user. in order to do this, we have to know what the choice the user submitted. this data can be retrieved by accessing the $_POST array. particularly, the name of the input field, like this: $_POST['Combo2'].

 

so you use this value and compare it to a string, 'Yes' or 'No'. if the data in $_POST['Combo2'] matches either one of those, it will add ' SELECTED' to the input field, making it 'pre-selected'. as illustrated in the code below:

<?php
        echo "
                <select name=\"Combo2\" size=\"1\" class=\"WorkPageField\" id=\"Combo2\">
                <option value=\"Yes\"". (($_POST['Combo2'] == 'Yes') ? (' SELECTED') : ('') .">Yes
                <option value=\"No\"". (($_POST['Combo2'] == 'No') ? (' SELECTED') : ('') .">No
                </select>
        ";
?>

Link to comment
Share on other sites

Dear Benjaminbeazy,

 

I am very touched you are trying your best, but it is not workin for me.

 

Dear Boo_lolly,

 

I am embaressed to say I do not know where to place your code into mine, can you please place it for me, please take the code Benjaminbeazy last posted, thanks.

Link to comment
Share on other sites

ok can you try this one for me?? btw, aer you hosting this on your computer or is this on the web. if on the web, i'd like to see it

 

 


<?

ini_set('error_reporting',8191);
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<?PHP
//Transfer Data from Screen to Memory
$NumberOfTxtBoxes=5;
$NumberOfTxtBoxesToBeFilled=5;

if(isset($_POST['Submit'])){


   $var1 = $_POST['var1'];
   $var2 = $_POST['var2'];


   for ($i=1; $i<=$NumberOfTxtBoxes; $i++)
   {
      $InputFromScreen[$i]=strtoupper($_POST["Txt".$i]);
   }
}
else
{
   for ($i=1; $i<=$NumberOfTxtBoxes; $i++)
   {
      $InputFromScreen[$i]="";
   }

$var1 ="";
$var2 ="";

}
?>
<form id="form1" name="form1" method="post" action="">
  <table width="200" border="1">
    <tr>
      <td> </td>
      <td><input name="Txt1" value="<?PHP echo $InputFromScreen[1]; ?>" type="text" id="Txt1" /></td>
    </tr>
    <tr>
      <td> </td>
      <td><input name="Txt2" value="<?PHP echo $InputFromScreen[2]; ?>" type="text" id="Txt2" /></td>
    </tr>
    <tr>
      <td> </td>
      <td><input name="Txt3" value="<?PHP echo $InputFromScreen[3]; ?>" type="text" id="Txt3" /></td>
    </tr>
    <tr>
      <td> </td>
      <td><input name="Txt4" value="<?PHP echo $InputFromScreen[4]; ?>" type="text" id="Txt4" /></td>
    </tr>
    <tr>
      <td> </td>
      <td><input name="Txt5" value="<?PHP echo $InputFromScreen[5]; ?>" type="text" id="Txt5" /></td>
    </tr>
    <tr>
      <td> </td>
   <td><select name="var2" size="1" class="WorkPageField" id="var2">
<option value="Yes" <?php if("Yes" == $var2){ echo "selected"; } ?>>Yes</option>
<option value="No" <?php if("No" == $var2){ echo "selected"; } ?>>No</option>
</select></td>
     </tr>
    <tr>
      <td> </td>
      <td><select name="var1" size="1" class="WorkPageField" id="var1">
<option value="Yes" <?php if("Yes" == $var1){ echo "selected"; } ?>>Yes</option>
<option value="No" <?php if("No" == $var1){ echo "selected"; } ?>>No</option>
</select></td>
    </tr>
    <tr>
      <td> </td>
      <td><?PHP
?></td>
    </tr>
    <tr>
      <td> </td>
      <td><input type="submit" name="Submit" value="Submit" /></td>
    </tr>
  </table>
</form>
</body>
</html>


Link to comment
Share on other sites

Dear Friend,

 

You have helped me twice today, this works.

 

If you are near me I will buy you a drink, I am in Singapore, where are you?

 

OK, I am working on my PC, I will settle my things at least 70% then I will hire server space if not I will be wasting money, I think no one want to give free server space for PHP MySQL right.

 

ini.set sounds too technical, I hope once i finished i will not have problem in my production server.

Link to comment
Share on other sites

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.