Asked  7 Months ago    Answers:  5   Viewed   32 times

I have some disabled inputs in a form and I want to send them to a server, but Chrome excludes them from the request.

Is there any workaround for this without adding a hidden field?

<form action="/Media/Add">
    <input type="hidden" name="Id" value="123" />

    <!-- this does not appear in request -->
    <input type="textbox" name="Percentage" value="100" disabled="disabled" /> 




Elements with the disabled attribute are not submitted or you can say their values are not posted (see the second bullet point under Step 3 in the HTML 5 spec for building the form data set).


<input type="textbox" name="Percentage" value="100" disabled="disabled" /> 

FYI, per 17.12.1 in the HTML 4 spec:

  1. Disabled controls do not receive focus.
  2. Disabled controls are skipped in tabbing navigation.
  3. Disabled controls cannot be successfully posted.

You can use readonly attribute in your case, by doing this you will be able to post your field's data.


<input type="textbox" name="Percentage" value="100" readonly="readonly" />

FYI, per 17.12.2 in the HTML 4 spec:

  1. Read-only elements receive focus but cannot be modified by the user.
  2. Read-only elements are included in tabbing navigation.
  3. Read-only elements are successfully posted.
Tuesday, June 1, 2021
answered 7 Months ago

Maybe you want to write name = "nv_select". You forget equal. Of course name atributes should be different nv_select1, nv_select2 etc.

Friday, May 28, 2021
answered 7 Months ago

Try this using javascript. It worked for me:

 <form name='searchdata' id="search_form" action="search.php" method="get">
                <div class="input-with-icon success-control">  
                    <input type="text" class="form-control" id="form1Amount"     name="searchvalue" placeholder="Search in users or #hashtags"><br/>
                <button onclick="form_submit()" name='user_search' value='user' class="btn btn-danger"><i class="fa fa-user"></i> User</button>
                <button onclick="form_submit()" name='tag_search' value='tag' class="btn btn-default"><i class="fa fa-tag"></i> Tags</button>           

  <script type="text/javascript">
  function form_submit() {
Monday, September 20, 2021
Mild Fuzz
answered 3 Months ago

There's apparently a bug in the way Firefox and Chrome handle padding in table cells in HTML5:

When you try your markup and CSS with 0 padding, they're the same. When you switch the DOCTYPE to be not HTML5 they are the same as well.

Thursday, October 7, 2021
Mahmoud Saleh
answered 2 Months ago

This is by design, disabled elements do not get submitted with the form.

What you are doing is actually a null practice, no matter what you do to that form in put it will be editable by the end user. You simply cannot trust form input - even hidden fields - to not be tampered with.

Your best bet is to just display the information to the user and load it again after the form has been submitted; at worst store it in a session.

Sunday, October 10, 2021
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :