【发布时间】:2022-01-27 18:45:25
【问题描述】:
我是 Rails 新手,我在下面有一个表单,我需要使用选择框中选择的选项(调整价格)更新文本字段(汽车价格)。下拉需要有多个百分比选项,如 100% 、 50% 和 25% 。 when one percentage is selected then it should update the car price in the field with new calculated adjusted price.
<% car = Car.find(params[:id]) %>
<table class="part" width="100%">
<tr style="vertical-align: top;">
<td><b>Car Model</b></td>
<td><b>Price</b></td>
<td><b>Adjusted price</b></td>
</tr>
<tr style="vertical-align: top;">
<td><%= text_field(‘Car’, ‘car_name’, size: 10, value: check_for_car_name(car.name)) %></td>
<td><%= text_field(‘Car’, ‘price’, size: 10, value: check_for_car_price(car.price)) %></td>
<td><%= select(adjusted price(not sure of this part)) %></td>
</tr>
</table>
我不确定如何即时更新汽车价格的选择框?提前致谢。
【问题讨论】:
标签: javascript jquery ruby-on-rails ruby ruby-on-rails-5