• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to iterate over Div and extract individual check box values?

 
James Dekker
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am very new to JavaScript / JQuery...

Need to iterate over the following segment of code and either return an array or single value the e-mail addresses assigned to these labels (these are hardcoded as the check boxes values):

Have written a JQuery event listener which does this:

Any help would be most appreciative...

Thank you for taking the time to read this!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
 
James Dekker
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much, Bear!

Quick question, how can I set it up that I know what e-mails are checked and once someone unchecks the "check" e-mail (by removing the check mark) what e-mails are unchecked?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The :checked filter will limit the wrapped set to just checked elements.
 
James Dekker
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,

But like I said, I am a JavaScript newbie and don't really understand where to put that filter in my code. Can you give me an example? What I need it to do is check multiple checkboxes (as an end user) and each time the checkboxes are checked to move the e-mails to an input text field. But, what ever ones are unchecked, to immediately remove them from the input text field (while keeping the remaining checked ones in).
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The filter is placed after the selector to be narrowed. For example: input:checkbox:checked filters the set of inputs to checkboxes that are checked.

You should probably pick up a copy of my book.
 
James Dekker
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,

So, how could I use input:checkbox:checked, in code, such as this:



I am going to pass in the result of this code to something like this:



And also use it to remove e-mails addresses placed in a input text field when an end user unchecks them?

Thank you for all of your help... Will definitely buy your book but probably in epub format!
 
James Dekker
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

I got it working with the filter:



And it dynamically removes e-mail addresses via unclicking the checkbox!
Thanks for telling me about it!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic