Search code examples
phphtmlminimized

How can you manipulate a minimized attribute value in HTML


I was wondering, since HTML5 brings a lot of minimized attributes to the table (and older HTML as well has those), for example autocomplete, another way of writing which could also be autocomplete="autocomplete" for XHTML, and the full version of the attribute.

The same with the disabled or disabled="disabled"

My question to you, is:
How to unset these attributes, how can I stop the form from autocompleting, or making an element not disabled again? Let's say I set via PHP something like disabled="<?php echo(x)?>", if I want to set something to be disabled, as much as I understand, I can put pretty much any value to x, and it will still be disabled? So like, if I type x = "disabled" or x = "randomword", it will behave the same and the element will be disabled. But is there a codeword for actually making it not work? Or how can you achieve this?

For example, I tried:
disabled="false"
disabled="off"
disabled="0"

And they don't seem to work. Maybe I'm not understanding the concept as a whole, and how can you solve this, could someone please tell me, how I can change these values dynamically and easily?

Thanks!


Solution

  • If you set disabled="SOMETHING", your input will be disabled. The only way to do what you want is to not put the disabled attributes in your form.

    Instead of disabled="<?php echo(x)?>", you can store disabled='disabled' in a var and print it only if it must be disabled.