![](/img/trans.png)
[英]Why isn't my JS function working when I call it through "onchange" in an html form?
[英]Why isn't my onchange function working?
我是ruby的新手,尝试在此处调用js函数onchange,但无法正常工作且未获得合适的答案。
= f.select :amendment_type, [['Renewal','renewal'],['Lease Amendment Agreement','Lease Amendment Agreement'],['Expansion','Expansion'],['Storage','Storage'],['Parking','Parking'],['Other(for me to fill in)','Other']], class: "amendment_type input", style: "width: 450px;", onchange: "alert('hello')"
select
方法参数为:
select(方法,选项=无,选项= {},html_options = {},&block)
您已经针对html_options
使用了options
,因此必须将代码替换为:
= f.select :amendment_type, [['Renewal','renewal'],['Lease Amendment Agreement','Lease Amendment Agreement'],['Expansion','Expansion'],['Storage','Storage'],['Parking','Parking'],['Other(for me to fill in)','Other']], {}, class: "amendment_type input", style: "width: 450px;", onchange: "alert('hello')"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.