-1

I want to disable my select option because is auto fill.
So the problem is that when I use readonly="readonly" and disable="disable" it changes into a disabled field but it sends null as value due to that my address is not updating. It's MVC template code, using backbone.js.

    <div class="login-register" data-validation="control">
      <select name="state123" id="state123" class="sumary state" disabled > 
        {{#each states}}
          <option value="{{code}}" {{#if selected}}selected{{/if}}>
            {{name}}
          </option>
        {{/each}}
      </select>
    </div>
<input type="hidden" name="state" id="state" class="cart-summary-estimate-input state" />
Salman
  • 333
  • 4
  • 18
  • 1
    What do you mean by _it send the null value...._ when does it happen? What the behavior you expect? – Krusader Oct 19 '17 at 06:10
  • basically it's part of address form so its mean due to null value of state address is not updating on the server. – Salman Oct 19 '17 at 06:13
  • So what the expected bahavior, what should it do instead? – Krusader Oct 19 '17 at 06:18
  • Expected behavior is that it should update address on server. It's required field so if state is null then address will not update. – Salman Oct 19 '17 at 06:20
  • The `disable` option is what is making that parameter not being sended. Use only the `readonly` option and it should be sended – A. Iglesias Oct 19 '17 at 06:31
  • both are not working. – Salman Oct 19 '17 at 06:32
  • I see (`readonly` is not available for `select`)... Then i guess the hidden field is the way to go... https://stackoverflow.com/questions/1191113/how-to-ensure-a-select-form-field-is-submitted-when-it-is-disabled – A. Iglesias Oct 19 '17 at 06:35
  • Possible duplicate of [How to ensure a – A. Iglesias Oct 19 '17 at 06:35
  • I have tried select with hidden input tag but it's not working. @A. Iglesias – Salman Oct 19 '17 at 07:01
  • Edit the question and show your html with the hidden field option, to see where's the error – A. Iglesias Oct 19 '17 at 07:05
  • Now check it..@A. Iglesias – Salman Oct 19 '17 at 07:38

1 Answers1

1

You haven't set the value of hidden input. It should be

<input type="hidden" name="state" value="{{code}}"/>
T J
  • 42,762
  • 13
  • 83
  • 138
  • @salmankhan you should set whatever value you want to submit as the value of state. It's an example – T J Oct 19 '17 at 11:12