我有一个问题应该不会那么困难,但我没有找到类似的东西,而且我不是铁路专家。我想通过collection_select将名称更改为数据库而不添加新数据。 我有这两个模型:
<%= form_for @plan do |f| %>
<%= javascript_include_tag "plans_DefaultstructureNames.js" %>
<p><strong>Please select the diagnose:</strong><br>
<%= f.collection_select :diagnose, ['SRS', 'SRT', 'SBRTLung', 'SBRTLiver', 'SBRTPancreas', 'SBRTProstate'], :to_s, :to_s, :include_blank => true,prompt: true%>
</p>
<div id="SrsSrtDefault">
<p>
<strong>BODY</strong>
<%= f.collection_select :plan,:structure,@plan.structure.name , :to_s, :to_s, :include_blank => true,prompt: true%>
</p>
<p>
<strong>PTV1</strong>
<%= f.collection_select :plan,:structure,@plan.structure.name , :to_s, :to_s, :include_blank => true,prompt: true%>
</p>
</div>
我上传了一些文件,这些文件在计划和结构中保存数据,例如计划名称,.. 我现在需要一个@plan的表单来填写诊断的类型,我还想用我决定的一些默认名称来更改结构的名称(因为上传文件中的结构名称在文件到文件之间是不同的但具有相同的含义)
//Store the values in here
var inputValues = [];
//Click event of non-final submit button
$(yourButton).on("click", function(e){
e.preventDefault();
var submit = confirm("Do you want to submit?");
if(submit){
//submit the values to the database
}
else{
//Add the current values to the array, this could be as many as you like
inputValues.push({
input1:$(yourInput).val(),
input2:$(yourInput2).val(),
input3:$(yourInput3).val(),
});
//Optional -- Clear the inputs, again as many as you like
$(yourInput).val('');
$(yourInput2).val('');
$(yourInput3).val('');
}
})
想象一下,@ plan.structure.name包含BOD和PTV1。我希望用户通过集合选择将BOD更改为BODY,但我真的没有clou .. 希望它清楚......干杯