wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes How to iterate over Div and extract individual check box values? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to iterate over Div and extract individual check box values?" Watch "How to iterate over Div and extract individual check box values?" New topic
Author

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

James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
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

Joined: Jan 10, 2002
Posts: 61315
    
  66

http://api.jquery.com/map/


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
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

Joined: Jan 10, 2002
Posts: 61315
    
  66

The :checked filter will limit the wrapped set to just checked elements.
James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
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

Joined: Jan 10, 2002
Posts: 61315
    
  66

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

Joined: Dec 09, 2006
Posts: 215
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

Joined: Dec 09, 2006
Posts: 215
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

Joined: Jan 10, 2002
Posts: 61315
    
  66

 
GeeCON Prague 2014
 
subject: How to iterate over Div and extract individual check box values?