aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Question on problem with addEvent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Question on problem with addEvent" Watch "Question on problem with addEvent" New topic
Author

Question on problem with addEvent

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

We're using mootools and I am new to mootools and I'm trying to change the color of a button based on 2 or more checkboxes clicked on my form. I can get the code to work in jsfiddle however I am working in the Oracle Workshop IDE using weblogic server (don't know if this makes a difference and thought I'd better state the environment).

The problem is the addEvent("click", function(ev) {... is not working. I can get alerts prior to this event in the code I just can't get an alert after. If someone could please take a look at my code below perhaps another set of eyes could find what my problem is. Any help/direction would be appreciated. Regards.

Here is my HTML code:




Here is my JS code:

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
ARe you sure that optionCheckboxes is returning results? Check the length.

Is there a reason why you do not use $$?

Eric
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

When I added an alert ("optionCheckboxes value " + optionCheckboxes); PRIOR to the addEvent("click", function(ev)... I get nothing not even a null value.

In my same code in jsfiddle, I get "optionCheckboxes value: [object Object]"

I'm not sure why I'm getting back an empty value within my app. The checkboxes are not suppose to get checked at this point as the page is just loaded.

I'm also not sure what is in the Object above. I look into that.

As far as the $$, can you elaborate on where I would be using that? Again, any help/direction would be appreciated as I'm new to mootools.

Thanks.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
First off, you should really be using the browser's built in console to debug your JavaScript. It is better than using alert.



Are you getting any elements?

Eric
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

Got back a 0
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
well looks like your program is changing the names. View the page source, are the names what you expect?

Eric
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

The jsp page where I added these checkboxes is nested I think the js file may NOT be viewed by the page in some form or another.

Sorry. I just found that out. I appreciate your time and help.

Regards.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
If the checkboxes are in the html, the JavaScript should be able to access them. You say that the first alert appears which means it is being called.

What does nested mean? Is it using frames/iframes?

I do not code MooTools, I just know the basics from using it a long time ago, but I would expect the code to look more like this

Basic idea


I used named functions instead out of habit.

Examples
Like you way with name http://jsfiddle.net/5hPbV/
Using a class instead of a name http://jsfiddle.net/5hPbV/1/


Eric

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on problem with addEvent
 
Similar Threads
loading tooltips after ajax request
jsf radio button and javascript
how to implement dynamic rows paging when user clicks next or previous links
Clear arraylist data in jsp using Ajax
Toolbar with color pallette ,different font styles and font sizes