0

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>
user1844933
  • 3,296
  • 2
  • 25
  • 42

2 Answers2

3

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>
John Sparwasser
  • 1,015
  • 13
  • 26
  • thanks, here another problem, 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? – user1844933 Jul 23 '13 at 04:45
  • Form fields with the disabled attribute do not send their value in the post array, maybe take a look at this question: http://stackoverflow.com/questions/1191113/disable-select-form-field-but-still-send-the-value – John Sparwasser Jul 23 '13 at 04:57
0

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>
Vipul
  • 309
  • 2
  • 11
  • Messy but I see your point about value. Maybe `foreach ($list as $k => $v) { echo '';}` – Ally Jul 22 '13 at 15:48