0

Please help me. I use Codeigniter.

In VIEW i have

'<select name="sender[]" style="width:150px" class="chzn-select" disabled='disabled'>
<?php foreach($statments as $statement): ?>
<option value="<? echo $statement->id; ?>" <?php echo ($statement->id==$pris->sender)?"selected='selected'":""; ?>><?php echo $statement->name; ?>'<?php endforeach; ?>

If i use "disabled" it passes "sender" as NULL. if i remove "disabled" it works fine, but i need not active select.

user2445177
  • 1
  • 1
  • 2

2 Answers2

3

A disabled element does not send its value in the POST.

If you want data to be passed but prevent users from editing the field, use readonly instead.

edit: Apparently, this isn't an option for <select> boxes. See HTML form readonly SELECT tag/input for a solution.

http://kreotekdev.wordpress.com/2007/11/08/disabled-vs-readonly-form-fields/

Community
  • 1
  • 1
ceejayoz
  • 176,543
  • 40
  • 303
  • 368
  • Thanks. But I solve problem this way. Found at http://stackoverflow.com/ :) `` – user2445177 Jun 02 '13 at 14:36
0

Would like to point out that the answer above is the best solution so far.

$('select option:not(:selected)').each(function(){ $(this).attr('disabled', 'disabled'); }); 

For the reason that, even when it's still disabled, the value still pass to the database without an error.