Disabled HTML input field no value sending - how to get value ?

I am trying to send the value from input field, that is disabled by javascript function. Value is assigned also by javascript function, but it is not sent. How can get the value from disabled input field ?
0
give a positive ratinggive a negative rating
19 Feb 2021 at 06:16 PM
Hi,

When input field is disabled, it has no form function. Because of that, the value appears in input field, but is not send when from is submitted. If you want to disallow editing of input field and send the assigned value, you have to use readonly instead of disabled attribute.

To send the value, instead of someting like this:

<input name="zip_code" id="id_zip" />

<a href="javascript:void(0);" onClick="javascript: document.getElementById('id_zip').value='12345'; document.getElementById('id_zip').disabled=true; ">Assign value</a>

use something like this:

<input name="zip_code" id="id_zip" />

<a href="javascript:void(0);" onClick="javascript: document.getElementById('id_zip').value='12345'; document.getElementById('id_zip').readOnly=true; ">Assign value</a>

0
give a positive ratinggive a negative rating
21 Feb 2021 at 04:39 PM
Tim
Share on FacebookShare on TwitterShare on LinkedInSend email
x
x
2024 AnswerTabsTermsContact us