MyBB Community Forums

Full Version: need JS for checkAll for use in ACP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am building an ACP plugin that has the potential for outputting a large number of rows, each with a check box form object. I need to be able to have a check all, uncheck all buttons/links but I can not get them to work.

As I need to use input names as arrays, I can't seem to get any JS code I can find for this to work.

Here is a snippet of the HTML I am outputting:

<form action="index.php?module=tools-afv&amp;action=action_to_perform" method="post" id="form_name">
<input type="hidden" name="my_post_key" value="XXXXXXXXXXXXXXXXXXXXXXXX" />
<div class="border_wrapper">
	<div class="title">Table title</div>
<table class="general form_container " cellspacing="0">
	<thead>
		<tr>
			<th class=" first">Some field title<input type="hidden" name="num_changes" value="13" /></th>
			<th class="align_center last" width="50">Checkbox field title</th>
		</tr>
	</thead>
	<tbody>
		<tr class="first">
			<td class="first">Some text<input type="hidden" name="content[0]" value="first content" /></td>
			<td class="align_center last" style="background:#99FF66"><label><input type="checkbox" name="saving[0]" value="true" class="checkbox_input" /> </label></td>
		</tr>
		<tr class="alt_row">
			<td class="first">Some more text<input type="hidden" name="content[1]" value="second content" /></td>
			<td class="align_center last" style="background:#FF4D4D"><label><input type="checkbox" name="saving[1]" value="true" class="checkbox_input" /> </label></td>
		</tr>
		<tr class="last alt_row">
			<td class="smalltext first" style="text-align:right" colspan="5"><input type="button" name="CheckAll" value="Check All" onClick="inlineModeration.checkAll(this)"><input type="button" name="UnCheckAll" value="Uncheck All" onClick="inlineModeration.uncheckAll(this)"></td>
		</tr>
	</tbody>
</table>
</div><div class="form_button_wrapper">
<input type="submit" value="Save Selected" class="submit_button" /> 
</div>
</form>
<script type="text/javascript" src="../jscripts/inline_moderation.js?ver=1600"></script>	

So I have tried the built in inlinemoderation CheckAll as you can see.

I have also tried several different things I found online, but none work.

It is much easier for me to process the data as an array once the form is submitted, so I'd like to keep that if possible.

If I need to change to the MyBB forumdisplay style of "name_1", "name_2" then I will but its not what I really want to do.

never mind, after a bunch of searching and trial and error I got it working.