Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove and not hide fields element in a form?

I want to remove a field from a form and not hide it because I want the form to retract when I hide the fields my form stays "wide" which is an aesthetic problem.

document.getElementById('test_field').style.visibility = "hidden";

it works but the form remains large (it only does the hidden)

I tried that but it doesn’t work

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

document.getElementById("test_field").style.display = "none"; 

edit: document.getElementById("test_field").remove() work thank you to "DaveS".

>Solution :

If display = "none" didn’t work for you, it sounds like you want it removed from the server’s point of view. In other words, you don’t want it to be submitted with the other fields. If that’s the case, you can just use document.getElementById("test_field").remove().

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading