You are viewing limited content. For full access, please sign in.

Question

Question

Making a single checkbox readonly

asked on December 28, 2017

I have attempted to put the readonly attribute for a single checkbox. I inspect the element and I can see the attribute readonly=readonly although you are still able to interact with the checkbox. Is there anyway to make a single selection readonly? The reason for this is that a default value is needed to be shown but not removable. 

0 0

Answer

SELECTED ANSWER
replied on December 29, 2017

I don't know if its actually possible to make only one selection read only but you could always re-check the box if it is changed.   Essentially making it read only.

Here the first check box ( Item 0 ) will be checked and not rechecked any time any checkbox is updated.

$(document).ready (function () {
	document.getElementById('Field7-0').checked = true;
  
	$('#q7').change(function(){
		document.getElementById('Field7-0').checked = true;
	})

});

~ Andrew

0 0
replied on January 2, 2018

This works great. Although not read only it forces the input. Thanks!

0 0

Replies

replied on January 2, 2018

Hi!

I am no good at Java, but if this is in forms, why not make the checkbox read only that way?

Hope I gave you an idea!

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.