• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on problem with addEvent

 
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got back a 0
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well looks like your program is changing the names. View the page source, are the names what you expect?

Eric
 
Melinda Savoy
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic