1

In my combobox certain condition i disable the combobox.But i want to access the values in the controller.Now i can't get it.Readonly not working

<select class="select2" id="branch" name="branch" required="required" onchange="getDept();" <?php if(!empty($detailone)){?> disabled="true" <?php } ?>>
Adarsh M Pallickal
  • 813
  • 3
  • 16
  • 37

3 Answers3

6

you can not get the value of disabled fields.you can use readonly=true instead of disabled. Like in your case :

<select class="select2" id="branch" name="branch" required="required" onchange="getDept();" <?php if(!empty($detailone)){?> readonly="true" <?php } ?>>
Harshal
  • 3,562
  • 9
  • 36
  • 65
  • 1
    @Harsha Mahajan read only not support fro select http://stackoverflow.com/questions/368813/html-form-readonly-select-tag-input –  Mar 19 '14 at 06:06
1

You cant't make is as readonly. Because not tag does't have any values . So you need to try better javascript to overcome this issue.

Try this

<select id="countries" onfocus="this.defaultIndex=this.selectedIndex;" onchange="this.selectedIndex=this.defaultIndex;">
<option value="1">Country1</option>
<option value="2">Country2</option>
<option value="3">Country3</option>
<option value="4">Country4</option>
<option value="5">Country5</option>
<option value="6">Country6</option>
<option value="7" selected="selected">Country7</option>
<option value="8">Country8</option>
<option value="9">Country9</option>
</select> 

Source

Community
  • 1
  • 1
1

Find a solution:

<option value="<?php echo $barn['id'];?>"<?php if(!empty($detailone)){ if($bid==$barn['id']){?> selected="selected"<?php }else {?> disabled="disabled" <?php }} ?>>
<?php echo $barn['b_name'];?></option>

Here i disable the values except the selected one

Adarsh M Pallickal
  • 813
  • 3
  • 16
  • 37