Unfortunately there still are forms were bulk/mass editing is not implemented. What can be very annoying, especially when you've a form with over 100 records what you've to update. In my case it's around 1000 records and each record has a checkbox what should be checked, currently they all are unchecked.
Therefor I tried to run an on-the-fly piece of javascript to check those boxes for me. However it did show a checkmarker at all checkboxes after running the javascript. After submission the form the first unchecked checkboxes - what were shown as checked checkbox - returned back to there original state (unchecked).
The on-the-fly javascript I executed from FireFox's console.
var x = document.querySelectorAll('input[name^="example"][type="checkbox"]'), i = 0;
for (i = 0; i < x.length; i++) {
x[i].checked = true;
x[i].value = true; // I also tried 'on'
}
The initial markup of checkboxes (manually) checked and unchecked:
<input name="example[1]" checked="" type="checkbox">
<input name="example[2]" type="checkbox">
As far as I know the checked
attribute is only there for visual representation, to allow programmers to show a checked box on initialization of the element. Also good to note is when you uncheck a checkbox than the element won't change.
Am I using the right approach? If so than what I'm doing wrong? Or do I've to use a different approach to reach my goal, what should I do?