Is there a button to reset all check boxes in a task list?

Robert Liberti April 10, 2015

I set up a tasklist with checkboxes that I would like to re-use.

It is inconvenient to have to uncheck each one - one at a time - when I want to reuse my page.  Is there a way I can make a button to reset all checkboxes?

5 answers

4 votes
Lee Cannon December 18, 2017

Sorry to necro this question but I have been looking for a solution to this for a while and have given up and writen a user macro to provide this functionality.

 

The code is available here

Diego Balbi October 2, 2018

Hi Lee! How can I get your javascript user macro enabled in my Confluence wiki page?

I appreciate your help.

Thank you a lot!

Simon Tost [TNG] January 18, 2019

You need to be a confluence admin.
Then you can define new user macros at Admin > Configuration > User Macros.
That is where you can paste the code provided.

Once that's saved, as a user:

You add the user macro on the page. It renders a button you can click on.

1 vote
Vincent Lepine November 25, 2019

This is what worked best for me and my needs based on @Lee Cannon 's code found here : 

 

{HTML Macro Start}

<button>onclick="untick()">Clear List</button>
<div id="taskList"> 

{HTML Macro End}

[ ] Task-1
[ ] Task-2
[ ] Task-3

{HTML Macro Start}

</div>
<script type="text/javascript">

function untick() {

var list = document.getElementById('taskList');
var base_url = window.location.protocol + "//" + window.location.host
var token = document.getElementById("atlassian-token").getAttribute("content")
var tasklist_id = list.getElementsByClassName("inline-task-list")[0].dataset.inlineTasksContentId;
var boxes = list.getElementsByClassName("checked");
var number_of_boxes = boxes.length;
var completed_boxes = 0;

for (i = number_of_boxes-1; i >= 0; i--) {
var task_id = boxes[i].dataset.inlineTaskId;
var xhttp = new XMLHttpRequest();
var url = base_url + "/rest/inlinetasks/1/task/" + tasklist_id + "/" + task_id + "/" xhttp.open("POST", url, true);
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.send('{"trigger": "VIEW_PAGE", "status": "UNCHECKED"}');
boxes[i].className = "";
}
}

</script>

{HTML Macro End}

 

- I ignored the request's response because I don't really care if it fails in my case (it never did.)

- I added a <div id="x"></div> around the tasks to limit my search range and avoid modifying other tasks.

- I removed the location.reload() to avoid reload blink and replaced it with a className = "" to remove the "checked" class.

 

Hope this helps!

1 vote
gustavo_refosco
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 10, 2015

Hi Robert,

I'm afraid this is currently not possible, but I've created a feature request for this at https://jira.atlassian.com/browse/CONF-37184. Please feel free to watch it to track its progress, as well as commenting and voting for it.

Regards,

Gustavo Refosco

0 votes
Khuong Vu February 28, 2019

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events