Jump to content

Disable Checkbox Javascript Or Css


Recommended Posts

I can't figure out a javascript to disable this checkbox, to the left of the Yes group.

dZps2wf.png

The script must check for Yes, because sometimes only the (blank) group exists, and sometimes only (blank) and Yes, and sometimes (blank) No and Yes. Can't use CSS as far as I can tell.

 

The goal is to prevent the mass-selection of Yes records.

 

I tried using some javascript browser addons to find an appropriate selector, but was my first time using and no luck. I also tried using .prev() in jQuery, but now I don't think the checkbox is a sibling. I tried modifying the code used to conditionally format rows, but those are inserted into HTML blocks for records, and so can't operate on Group rows.

 

Thanks in advance!

Link to comment
Share on other sites

Now, I understand what you meant by 

 

 

The script must check for Yes, because sometimes only the (blank) group exists, and sometimes only (blank) and Yes, and sometimes (blank) No and Yes. Can't use CSS as far as I can tell.

You mean it won't always be in the same position, relative to counting the number of elements.

 

You could fix that if you put yes, on top and make it always show,,, even if there aren't records in yes.

This hides the checkbox next to "no", and if you put yes there, you can get what you're after.

tr[data-cb-name="group1"]:nth-child(2) input[type="checkbox"] {
    display: none;
}

I think this might require jQuery

Link to comment
Share on other sites

I think I got it. This works in a footer element  HTML block (so that it runs after AJAX updates, instead of just once) when the column with data matching Yes is the first column following the checkbox.

 

<SCRIPT LANGUAGE="JavaScript">
var elems = document.getElementsByTagName("td");
for (var i=0, m=elems.length; i<m; i++) {
if (elems.innerHTML=="Yes")  { elems.previousSibling.style.display="none";}
}
</SCRIPT>
 
edit: if you have other data that might =Yes, then you might have to modify this. In my case, Yes can only appear in the one place that I'm targetting.
Link to comment
Share on other sites

Nice work, that isn't simple js.

 

 

 

That's clever, I hadn't thought of that, but I'm dealing with users who:

  • need to see blank/No more importantly than Yes. I don't want blank/No "below the fold"
  • are used to seeing it the other way
  • aren't savvy
  • complain a lot

Most users my friend.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...