0

I have a simple code, which goes with a more complex code though I will only be showing the snippet in the object notation.

var test = {
    add: {
        select: function(options){
            console.log(options.id);
            console.log(options.className);
            onchange: function(){
             //code here
            } 
        }
    }
}

That is the code above, as I've tried many instances to make this work firing Vanilla JS or even jQuery to make it fire. The code to make it work would look like this-

test.add.select({
    id:'id',
    className: 'class',
    onchange: function(){
        if(key===0){
            console.log('0');
        }else if(key===1){
            console.log('0');
        }else if(key===2){
            console.log('0');
        }
    }
});

Key is being set as the actual select menu key. Please see the JSBIN for a much better visual.

http://jsbin.com/amonid/1/edit

Basically when the select is change for now console.logging is what I am doing, later on I will change it for the needs I have. Can someone explain to me how I would go about adding this all?

oleq
  • 15,697
  • 1
  • 38
  • 65
EasyBB
  • 6,176
  • 9
  • 47
  • 77
  • yes lol my bad I'll fix that – EasyBB Aug 01 '13 at 20:27
  • You have syntax errors at many places. That's why it doesn't work. You omit the `function` keyword a few times, for instance `onchange:{` should be `onchange: function () {` but there are other errors as well. Use [JSHint](http://www.jshint.com/) to lint your code. – plalx Aug 01 '13 at 20:32
  • This isn't the actual code here, the jsbin is the best code provided, also in the code when I write the function it gives errors. Where are you saying to add the `onchange:function() {` ? – EasyBB Aug 01 '13 at 20:38
  • Anyone care to provide some sort of path to help? Where I'm going wrong how to get it to do what I want... http://jsbin.com/amonid/1/edit is the new link – EasyBB Aug 01 '13 at 21:31

0 Answers0