Help to block a form field

Asked

Viewed 246 times

0

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

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

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

What other way to block the field and write in the bd that value received in the product selection?

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

the form is 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>
  • Tried using javascript like this Document.getElementById("myText"). readonly = true;

  • Ever tried to put "disable"? (without the quotation marks).

  • I believe you are giving some error because you are using readonly="readonly", try to put only readonly This answer has some things you may be interested in https://answall.com/questions/313349/existe-diff%C3%A7a-in-use-attributes-Html5-with-or-without-true-false/

  • Leandro already used disable without quotes and even so it does not record in BD Hugocsl I tried also only readonly and even so lets change

  • If you can take the input, put the value inside a <p></p>

  • Without the imput the value will not appear on the screen

  • Puts type="Hidden" in the input and puts the value out of the field as well.

  • dvd.... thank you hadn’t thought of that possibility...

Show 3 more comments

1 answer

1


Place type="hidden" in the input with the value and outside it as well. Thus the value will be visible to the user on <td> and the input hidden will also keep 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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.