I m really sorry if this come across as stupid but i ve searched everywhere but i didn t find any tip on how to go about it. i have this variable
var id = $( #sometextfield ).val();
这一案文的外地价值是动态产生的。
<input type="text" name="id" id="id" value="<?php echo $_get[something];?>" />)
这里的问题是,如果情况是这样的话。
if(id == 100 || id ==120) {
// i have these variables
var mulitiplier = 0.005
var price = (some alog) * mulitiplier;
// do some very long piece of code
}
else if (id == 200 || id == 220) {
// Then i have these variables
var mulitiplier = 0.090;
var price = (some alog) * mulitiplier;
// Do the same very long piece of code(its practically the same thing as
// the first if statement and the only change is the ariable multiplier)
}
This works and all but is there any way to not repeat the same thing. I don t like the look of it atm. Many thanks in advance..