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
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>

Share on FacebookShare on TwitterShare on LinkedInSend email
1 answer
x
x
2024 AnswerTabsTermsContact us