Reputation: 3417
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
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
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