I am doing a `fixeddeposit` project, in which I am having three models:

1)`fixeddeposit`
2)`interestrate`
3)`interestsetup` 

When I open a `fixeddeposit`, I have to type the number of days(365/730/1095/1460 & 1825) from `number_field`. Then in another text box I want to update the `rate_of_interest` based upon the number(365/730/1095/1460 & 1825) I typed. 

Rate\_of\_interest should be taken from rate which is in the interestrates table field. Kindly see the screenshot of my interestrates table below.

**Interestrates table**

![enter image description here](https://i.stack.imgur.com/mXZLI.png)![enter image description here](https://i.stack.imgur.com/Wite1.png)

Example:

If i type number 365 in fixeddeposit form(which is number\_field). It automatically select rate 9.5% from interestrates table using AJAX function.

And, if a customer age is above 58, and i type number 365 in fixeddeposit form. It automatically select (rate 9.5% + senior increment 0.5% ) = 10.0% from interestrates table using AJAX function.

**Screenshot of FD**
![enter image description here](https://i.stack.imgur.com/DNlop.png)

I googled it for a solution but, results showing with collection\_select alone. I want to do the same in number\_field. Though, i am new to Ruby on Rails and AJAX i am struggling with it.