0
I need a script that enables and disables a field with READONLY from a checkbox I don’t know how to program in javascript, How do this script
<input readonly="" type="text" name="xx" value=""
<input readonly="" type="text" name="xx" value=""
<input readonly="" type="text" name="xx" value=""
Editar:<input type="checkbox" name="check" value="sim" />
<input type="submit" value="Salvar Dados" /></p>
So if I check the checkbox releases all fields for editing
Perfect... that’s right... just a detail?? when enabled, the background could be with a different color or to show that the field is enabled for editing. this is complicated?
– Fabio Henrique
You can create a css class with this background color and add in the enabled input by adding
inputs[i].className += " nomeDaMinhaClasse";
However for UX reasons do not advise modifying the background of the field because it is default, you could just override the readonly css to leave it with a disabled appearance.– Gabriel Rodrigues
Show only has a problem that <form is in a lightbox if I disable the checkbox it disables the fields that are in the page below the lightbox, I think these fields would have to be idetified by an id
– Fabio Henrique
The proposed problem to be solved is that of the example in your question above, if you have not detailed it correctly edit to fit your problem. Answering your question, do you have any difficulty in removing the for and putting fixed each id and setting the readonly? is the same logic only fixed
– Gabriel Rodrigues
I didn’t detail it because I didn’t know that the script going into the lightbox would interfere with the parent page. the logic I understood I don’t know how I change the command to traverse by id
– Fabio Henrique
@Fabiohenrique can do it this way: https://jsfiddle.net/o76ag8y8/
– Gabriel Rodrigues
Perfect now thank you
– Fabio Henrique
@Fabiohenrique do not forget to mark the answer as correct in case she has managed to solve the problem.
– Gabriel Rodrigues