Make "checkable" radio buttons: HTML

How to make the switches look more like a checkbox? I need a switch function, but it needs to be removed.

+3
source share
4 answers

This is usually accomplished by adding another "No" option. Users did not expect that clicking on the selected radio button cancels it, as this is not normal behavior.

Another option that is not often used anymore is the clear button. I don't like this option though.

+12
source

"none" javascript . , onclick , ...

+3

onClick , , ( , ). - , , "", .

EDIT: , . . - .

<script>
  var x = false;
</script>

<input type="radio" value="test 1" name="1" onmousedown="if (this.checked) { x = true; }" onclick="if (x) {this.checked = false; x = false; return true;}" />1
<input type="radio" value="test 2" name="1" onmousedown="if (this.checked) { x = true; }" onclick="if (x) {this.checked = false; x = false; return true;}" />2
<input type="radio" value="test 3" name="1" onmousedown="if (this.checked) { x = true; }" onclick="if (x) {this.checked = false; x = false; return true;}" />3
+2

"none", . , :

  • .
  • , .
+1

Source: https://habr.com/ru/post/1729934/


All Articles