View Full Version : case switch help!

22 Mar 2011, 9:58 AM
Ok so this is my first time using case switch in js.

select: function(combo, value, condition) {
case 'BETWEEN':
this.condition = 'BETWEEN'
condition is a value im getting from a combobox in my getvalue method.

getValue: function(){
var condition = this.numbercombo.getValue();
var input = this.txtfield.getValue();
var position = this.hidposition.getValue();
return condition + this.delimiter + input + this.delimiter + position;

I am not sure if I am writing the code in the correct format or do I need to redeclare the variable?

22 Mar 2011, 1:45 PM
I'm not entirely sure without seeing all the code, but I suspect your problem is what you're switching on. This line is probably wrong:


that's not using the condition that was passed into the function. Instead, it's looking for a field on 'this' (which might refer to different things depending on how the function was called).

You probably want to write:


that will refer to the 'condition' passed into the function.

What does the code look like that calls your function? What values are being passed in for condition? If I were you, I'd set a breakpoint within that switch block and look at the values of condition and this.condition and see how they differ, etc.

24 Mar 2011, 6:57 AM
ok so I figured out the switch case part, but now I am having trouble with another aspect of it. I think its a problem with hideMode. If you look at my test combobox
The second one, not the first, but I want the field or the double to show in the same place, any ideas why they would show next to each other instead of in the same spot?