0
votes

I would like to disable form select option for non admin users, so I wrote code as follows, there after element disabled, list populated but after submit there is no value in post variable... $_POST['abc'] is empty... Can't we read disabled element's content value through post variable?

    <HTML>
    <body>
    <form>
    <select name="abc" id="abc" $disable>
            <?php 
          foreach ($list as $value) {
           echo("<option>$value</option>");   
          } ?>      
    </select>
<input type="submit" name="submit" id="Show" value="Show">
    </form>
    </body>
    </HTML>
2
You're going to want to print $disable: <select name="abc" id="abc" <?php echo $disable;?> > - nickb
1. Are you sure $list is an array and populated? 2. Your echo doesn't need parenthesis. - Ally

2 Answers

3
votes

Try this instead, you're not echoing the $disable variable.

<HTML>
<body>
<form>
<select name="abc" id="abc" <?=$disable ?> >
        <?php 
      foreach ($list as $value) {
       echo("<option>$value</option>");   
      } ?>      
</select>
</form>
</body>
</HTML>
0
votes

try this :

<HTML>
<body>
<form>
<select name="abc" id="abc" >
        <?php 
      foreach ($list as $value) { ?>
       <option value = "<?php echo $value; ?>"><?php echo $value; ?></option>
      <?php } ?>      
</select>
</form>
</body>
</HTML>