javascript - Programmatically check checkboxes for submission of a webform -


unfortunately there still forms bulk/mass editing not implemented. can annoying, when you've form on 100 records you've update. in case it's around 1000 records , each record has checkbox should checked, unchecked.

therefor tried run on-the-fly piece of javascript check boxes me. did show checkmarker @ checkboxes after running javascript. after submission form first unchecked checkboxes - shown checked checkbox - returned there original state (unchecked).

the on-the-fly javascript executed firefox's console.

var x = document.queryselectorall('input[name^="example"][type="checkbox"]'), = 0; (i = 0; < x.length; i++) {     x[i].checked = true;     x[i].value = true; // tried 'on' } 

the initial markup of checkboxes (manually) checked , unchecked:

<input name="example[1]" checked="" type="checkbox"> <input name="example[2]" type="checkbox"> 

as far know checked attribute there visual representation, allow programmers show checked box on initialization of element. note when uncheck checkbox element won't change.

am using right approach? if i'm doing wrong? or i've use different approach reach goal, should do?

try using following:-

x[i].setattribute('checked', 'checked'); 

if inspect input after running original code can see sets value attribute

<input name="example[2]" type="checkbox" value="true"> 

this differs html manually click checkbox, checked attribute has been set.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -