southbeach
Programmer
I have a method within which I use
varstr is passed via json and as you can see, I'm referencing four possible variables. I know there's gotta be a way to shrink this.
What would you suggest?
The code I have work, but I figure I look for alternative for educational purpose and in search for simpler coding style.
thanks,
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
Code:
var prcLevel=$("#orderEntryForm select[name=pricelevel]").val();
var iPrice=0; var iDisc=0;
switch(prcLevel) {
case '0':
iPrice=varstr.sellprice0;
iDisc=varstr.disc0;
break;
case '1':
iPrice=varstr.sellprice1;
iDisc=varstr.disc1;
break;
case '2':
iPrice=varstr.sellprice2;
iDisc=varstr.disc2;
break;
case '3':
iPrice=varstr.sellprice3;
iDisc=varstr.disc3;
break;
}
What would you suggest?
The code I have work, but I figure I look for alternative for educational purpose and in search for simpler coding style.
thanks,
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.