[help]is there any way to make this jquery code shorter and efficient

Hi to all my fellow css-trickers, my client asked me to create a loan slider for his client’s website. The formula to calculate the interest rate is so complicated to understand so he told me to give fixed interest rates for each month and loan cost.

Below is my jquery code to make this work and so far I’ve managed to make this loan slider work for 12 and 24 months duration.

Obviously, my jquery code would contain more lines of code if i’ll include the last 3 durations left. I plan to use an array here to store the values of the loan costs for each duration but i don’t know where to start as I don’t usually use array. Or does using an array here adviceable? Thanks.

Also, here is the link for the project im developing. This is just a prototype so you can clearly visualize what im trying to say.

Hi nikuls, thanks for your effort in helping me. the problem with the code above is that when i try to increase the loan cost, the monthly payment don’t appear as it don’t get the index of the 12 and 24 month duration. So i made a few tweaks with the code you gave me and here is my code

Tips

What now? I have some ideas for you.

Go explore CodePen!

As a front end designer and developer, you should have an account on CodePen so you can save your snippets, present your ideas, and engage with the rest other front end folk. I'd encourage you to go PRO as well, to unlock the full power of CodePen.

Get the newsletter!

You should sign up for the CSS-Tricks newsletter. It's a clean copy of all the blog posts each week, combined together, right to your inbox. If email isn't your thing, there is an RSS feed, iTunes, and lots of other ways to subscribe.

Listen to ShopTalk!

Subscribe to The Lodge!

The Lodge is a members-only, ad-free video learning area here on CSS-Tricks. Just like the free screencasts, but organized into four large complete series. Membership is also the #1 best way to support CSS-Tricks.

We can do the real footer now.

Site Links

Colophon

CSS-Tricks* is created, written by, and maintained by Chris Coyier. It is built on WordPress, hosted by Media Temple, and the assets are served by MaxCDN. The fonts are Source Sans and Source Code Pro. It is made possible by viewers like you who subscribe to The Lodge and through advertising for products and services I like.