user1844933
user1844933

Reputation: 3417

PHP Form element select list value not showing in post variable after submit

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>

Upvotes: 0

Views: 2262

Answers (2)

Vipul
Vipul

Reputation: 325

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>

Upvotes: 0

John Sparwasser
John Sparwasser

Reputation: 1015

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>

Upvotes: 3

Related Questions