Webmastersite.net
Register Log In

Check All / Uncheck All

Title Check All / Uncheck All
Description Sample javascript on bulkedit links page
Message Text I'm doing a lot of bulk add links, because of this I get a lot of crappy links in the wrong category. I'm using the filter on "bulkedit links" to display all the crappy links or display all the links that should go into a particular category. For me, most of the time I use bulkedit links I want to check all the links that show up under the filter I used. I wanted to add a check all/uncheck all javascript link. However the selection[linkid] array was more than my limited javascript skills could handle. So I used code from this page His license seems to allow me to use this code, and probably you, although your more knowledgable on reusing code in commercial software. Was thinking you may want to incorporate it into the default templates.

<script type="text/javascript"><!--

var formblock;
var forminputs;

function prepare() {
formblock= document.getElementById('form_id');
forminputs = formblock.getElementsByTagName('input');
}

function select_all(name, value) {
for (i = 0; i < forminputs.length; i++) {
// regex here to check name attribute
var regex = new RegExp(name, "i");
if (regex.test(forminputs[i].getAttribute('name'))) {
if (value == '1') {
forminputs[i].checked = true;
} else {
forminputs[i].checked = false;
}
}
}
}

if (window.addEventListener) {
window.addEventListener("load", prepare, false);
} else if (window.attachEvent) {
window.attachEvent("onload", prepare)
} else if (document.getElementById) {
window.onload = prepare;
}

//--></script>


<div class="title">Bulk Edit {P_PLURALLINKS}</div>
<br>

<form action="https://www.webmastersite.net/forums/bulklinks.php" method="post">
<div class="sort">
Show {PLURALLINKS} where <select name="field">{OPTIONSLINKFIELDS}</select> 
<select name="condition">
 <option value="LIKE">contains</option>
 <option value="NOT LIKE">does not contain</option>
 <option value="=">is exactly</option>
 <option value="!=">is not</option>
 <option value=">">is greater than</option>
 <option value="<">is less than</option> 
</select>
<input type="text" name="fieldvalue" size="10"> 
<input type="submit" value="Show" class="button">
</div>
</form>

<form id="form_id" name="bulkedit" action="https://www.webmastersite.net/forums/bulklinks.php?filled=1" method="post">
<table>
<tr>
<td {COLUMNHEADER}> </td>
<td {COLUMNHEADER}>Title</td>
<td {COLUMNHEADER}>Description</td>
<IF {SCRIPTNAME} is wsnlinks><td {COLUMNHEADER}>URL</td></IF>
</tr>
<!-- BEGIN LINKS -->
<tr>
 <td class="oddcolumns"><input type="checkbox" name="selection[{LINKID}]" value="1"></td>
 <td class="evencolumns"><input type="text" name="title[{LINKID}]" value="{LINKTITLE}" size="30"></td>
 <td class="oddcolumns"><textarea name="description[{LINKID}]" rows="2" cols="40">{LINKDESCRIPTION}</textarea></td>
 <IF {SCRIPTNAME} is wsnlinks><td class="evencolumns"><input type="text" name="url[{LINKID}]" value="{LINKURL}" size="30"></td></IF>
</tr>
<!-- END LINKS -->
</table>
<IF {MULTIPAGE}>
<p>Page: {PREVIOUS} <b>{CURRENTPAGE}</b> {NEXT}</p>
</IF>

<p><a href="#" onClick="select_all('selection', '1');">Check All</a> | <a href="#" onClick="select_all('selection', '0');">Uncheck All</a></p>

<p>With selected, 
<select name="action">
 <option value="nothing">ignore selections, just edit</option>
 <option value="delete">delete</option>
 <option value="move">move to another category</option>
 <option value="alias">alias to another category</option>
</select>
<br>If moving or aliasing, select a category: 
<IF {SWITCH_CATSELECTOR}>
<select name="newcategory"><option value="">not applicable</option>{CATOPTIONS}</select>
<ELSE>
<input type="text" name="newcategory" size="6"> (type id number)
</IF>
</p>
<p><input type="submit" value="Save Changes" class="button"></p>
</form>
Rating
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5
0/5 based on 0 votes.
Ownership mrowton
Views 666 views. Averaging 0 views per day.
Similar Topics
Submission Date Aug 11, 2007 - 8:44 AM