ajax - Parse page for checkboxes via javascript -


I have a bunch of checkboxes that are dynamically created on page loads and written as:

< Pre> & lt; Input type = 'checkbox' name = 'quicklinkscb' id = 'quicklinkscb_XX' / & gt;

Where XX represents the item ID from the database.

I want to be able to parse the page for all the checkboxes via javascript and:

Find your ID and paste 'quicklinksscb_' from it and:

  if (checkbox is checked) {add to add list} and {add to delete list}  

I check this through the checkbox list And I want to do all this client side.

Does anyone shed light

< Div class = "post-text" itemprop = "text">

 for  (var i = 0; i & lt; document.forms.length; i ++) {for (var j = 0; J & lt; document.forms [i] .elements.length; j ++) {var elem = document.forms [i] .elements [j]; If (elem.type == 'checkbox') var tag = elem.getAttribute ('id'); Tag.replace (/ ^ quicklinkscb_ /, ''); If (elem.checked) add_to_add_list (tag); And add_to_remove_list (tag); }}  

Very easy in jQuery:

  $ (': checkbox'). Every (function () {var tag = $ (this). Attr ('id'); tag.rele (/ ^ QuickLinkCB_ /, ''); if ($ (this) .attr ('checked')) add_to_add_list ( Tag); else add_to_remove_list (tag);});  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -