PDA

View Full Version : case switch help!



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


select: function(combo, value, condition) {
switch(this.condition){
case 'BETWEEN':
this.condition = 'BETWEEN'
this.numrangefield.show();
this.numrangefield.enable();
this.txtfield.allowBlank(true);
combo.ownerCt.doLayout();
break;
}
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?

uooq
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:

switch(this.condition)

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:

switch(condition)

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.

Gamer
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
http://www.carterbillboards.com/ext-3.2.0/examples/ngamer/search_orders.html
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?