wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes struts, .click, names, jQuery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "struts, .click, names, jQuery" Watch "struts, .click, names, jQuery" New topic
Author

struts, .click, names, jQuery

Clayton Cramer
Ranch Hand

Joined: Aug 26, 2010
Posts: 41
The guy that really knew jQuery left a couple of weeks ago, so I am trying to take over. I have a JSP with a checkbox for ALL hearing types, and then a multibox for selecting one or more of several hearing types. I would like some control over the process, so that when a user unclicks the ALL checkbox, he can go select individual multibox choices, or if he he unclicks one of the multibox choices, it will unclikc the ALL box.

I am not being successful at getting the click function called when the user changes either the ALL checkbox, or any of the multiboxes. Here is the checkbox for ALL.



And the multibox for the different hearing types:



My expectation was that I could write these click event handlers to get control:
While the document ready event handler gets called just fine, these click handlers do not. I have tried a number of combinations of #, ., styleId, without success. There are apparently dozens of different ways to do this--and I just haven't found the right combination. Even worse, the jQuery guru used jQuery a different way every time he did something, so there is no particular pattern to follow. Help!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

Please repost the HTML code in question without Struts markup. jQuery (indeed, any JavaScript) operates on the rendered HTML, not the server-side tags.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Clayton Cramer
Ranch Hand

Joined: Aug 26, 2010
Posts: 41
Bear Bibeault wrote:Please repost the HTML code in question without Struts markup. jQuery (indeed, any JavaScript) operates on the rendered HTML, not the server-side tags.


I presume you mean the source that appears in the browser:



This is what comes out from View Source.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

I was more interested in the structural markup.
Clayton Cramer
Ranch Hand

Joined: Aug 26, 2010
Posts: 41
Thanks. My missing jQuery ninja showed up. Then as I explained it, it became obvious: I had moved the click functions outside the ready function, so they weren't being bound.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

Ah yes... outside the ready handler(s), the DOM hadn't been built yet, so there was nothing to assign the click handlers to.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: struts, .click, names, jQuery
 
Similar Threads
Multibox reset method ?
howto settle multibox problem ?
struts and multibox
Iterator and multibox
Problem with CheckBox and MultiBox