Hi,

I need some help with my code.

I have everything working but I intend to turn it more simple and small.

I have a form that a user choose between two dates and the choose a category. Then in javascript code calculate the total of days, check if the days are in a low, medium or high season and then go to a table with prices and then return the full price.

This is part of my code:

And I have this from the letter "A" to "J".Code:var a_low_2=39; var a_low_4=55; var a_low_5=68; var a_low_7=88; var a_mid_2=63; var a_mid_4=88; var a_mid_5=110; var a_mid_7=129; var a_high_2=75; var a_high_4=110; var a_high_5=130; var a_high_7=173; var a1_low_2=58; var a1_low_4=116; var a1_low_5=145; var a1_low_7=196; var a1_mid_2=224; var a1_mid_4=116; var a1_mid_5=145; var a1_mid_7=196; var a1_high_2=58; var a1_high_4=116; var a1_high_5=145; var a1_high_7=196; if (season=="low" && car_choose=="a") { switch(total_days) { case 1: payment=a_low_2; break; case 2: payment=a_low_2; break; case 3: payment=a_low_4; break; case 4: payment=a_low_4; break; case 5: payment=a_low_5; break; case 6: payment=a_low_7; break; case 7: payment=a_low_7; break; default: payment=(a_low_7/7)*total_days; } } if (season=="mid" && car_choose=="a") { switch(total_days) { case 1: payment=a_mid_2; break; case 2: payment=a_mid_2; break; case 3: payment=a_mid_4; break; case 4: payment=a_mid_4; break; case 5: payment=a_mid_5; break; case 6: payment=a_mid_7; break; case 7: payment=a_mid_7; break; default: payment=(a_mid_7/7)*total_days; } } if (season=="high" && car_choose=="a") { switch(total_days) { case 1: payment=a_high_2; break; case 2: payment=a_high_2; break; case 3: payment=a_high_4; break; case 4: payment=a_high_4; break; case 5: payment=a_high_5; break; case 6: payment=a_high_7; break; case 7: payment=a_high_7; break; default: payment=(a_high_7/7)*total_days; } } if (season=="low" && car_choose=="a1") { switch(total_days) { case 1: payment=a1_low_2; break; case 2: payment=a1_low_2; break; case 3: payment=a1_low_4; break; case 4: payment=a1_low_4; break; case 5: payment=a1_low_5; break; case 6: payment=a1_low_7; break; case 7: payment=a1_low_7; break; default: payment=(a1_low_7/7)*total_days; } } if (season=="mid" && car_choose=="a1") { switch(total_days) { case 1: payment=a1_mid_2; break; case 2: payment=a1_mid_2; break; case 3: payment=a1_mid_4; break; case 4: payment=a1_mid_4; break; case 5: payment=a1_mid_5; break; case 6: payment=a1_mid_7; break; case 7: payment=a1_mid_7; break; default: payment=(a1_mid_7/7)*total_days; } } if (season=="high" && car_choose=="a1") { switch(total_days) { case 1: payment=a1_high_2; break; case 2: payment=a1_high_2; break; case 3: payment=a1_high_4; break; case 4: payment=a1_high_4; break; case 5: payment=a1_high_5; break; case 6: payment=a1_high_7; break; case 7: payment=a1_high_7; break; default: payment=(a1_high_7/7)*total_days; } }

I pretend to have something more simples like:

But the result of this code is the name of the variable, not the value.Code:if (season=="low") { switch(total_days) { case 1: payment=car_choose + _low_2; break; case 2: payment=car_choose + _low_2; break; case 3: payment=car_choose + _low_4; break; case 4: payment=car_choose + _low_4; break; case 5: payment=car_choose + _low_5; break; case 6: payment=car_choose + _low_7; break; case 7: payment=car_choose + _low_7; break; default: payment=(car_choose + _low_7/7)*total_days; } } //And the same for the other two seasons...

Can someone tell me how can I join 2 variable to turn in to one and the get the value of that variable e note the name?

Thank you in advance.