Help to block a form field

0

I have a form where you place purchase orders when the user chooses the product he automatically charges the price, the problem is that the unit value field is free for changes and I need to block that field.

I tried the normal one that is readonly="readonly" but it continues allowing changes.

I tried with disabled this disable the field for changes but also does not write this value in bd

What other means of blocking the field and recording in bd this received value in the product selection?

PS: I have other fields in this form that use readonly="readonly" that works perfectly like for example the result of the multiplication of qtd by the unit price the total field of the item the user can not change

The form looks like this:

<td> 
<input name="valor_unid[]" type="text" required name="valor_unid"  
maxlength="30" size="11" style="text-align:center" class="valor_unid" />
</td>
    
asked by anonymous 15.07.2018 / 01:11

1 answer

1

Put type="hidden" in input with value and outside it too. So the value will be visible to the user in <td> and hidden input will also save the same value:

<td>
    <?php echo $valor ?>
    <input type="hidden" value="<?php echo $valor ?>" name="valor_unid[]" type="text" required name="valor_unid" maxlength="30" size="11" style="text-align:center" class="valor_unid" />
</td>
    
16.07.2018 / 02:23